
- SwiftUI - Home
- SwiftUI - Overview
- SwiftUI vs UIkit
- SwiftUI Environment
- SwiftUI - Environment Setup
- SwiftUI - Basic Components
- SwiftUI - Building First Application
- SwiftUI Views
- SwiftUI - Views
- SwiftUI - Customize Text View
- SwiftUI - Custom Image View
- SwiftUI - Stacks
- SwiftUI Drawing Shapes
- SwiftUI - Shapes
- SwiftUI - Drawing line
- SwiftUI - Drawing Rectangle
- SwiftUI - Drawing Rounded Rectangle
- SwiftUI - Drawing Triangle
- SwiftUI - Drawing Circle
- SwiftUI - Drawing Star
- SwiftUI - Drawing Polygon
- SwiftUI - Drawing Pie chart
- SwiftUI - Using built-in shapes
- SwiftUI - Text
- SwiftUI - Text View
- SwiftUI - Text Input and Output
- SwiftUI - Color
- SwiftUI - Color
- SwiftUI - Colorpicker
- SwiftUI - Gradients
- SwiftUI - Adjust Color
- SwiftUI - Effects
- SwiftUI - Effects
- SwiftUI - Blend Effect
- SwiftUI - BLur Effect
- SwiftUI - Shadow Effect
- SwiftUI - Hover Effect
- SwiftUI - Animations
- SwiftUI - Animations
- SwiftUI - Creating Animations
- SwiftUI - Creating an Explicit Animation
- SwiftUI - Multiple Animations
- SwiftUI - Transitions
- SwiftUI - Asymmetric Transition
- SwiftUI - Custom Transition
- SwiftUI - Image
- SwiftUI - Images
- SwiftUI - Image as Background
- SwiftUI - Rotating Image
- SwiftUI - Media
- SwiftUI - View Layout
- SwiftUI - View Layout
- SwiftUI - View Size
- SwiftUI - View Spacing
- SwiftUI - View Padding
- SwiftUI - UI Controls
- SwiftUI - UI Controls
- SwiftUI - Button
- SwiftUI - CheckBox
- SwiftUI - Menubar
- SwiftUI - Toolbar
- SwiftUI - Search Bar
- SwiftUI - TextField
- SwiftUI - Slider
- SwiftUI - Toggle
- SwiftUI - Pickers
- SwiftUI - Menus
- SwiftUI - List & Tables
- SwiftUI - Lists
- SwiftUI - Static List
- SwiftUI - Dynamic List
- SwiftUI - Customize List
- SwiftUI - Tables
- SwiftUI - Forms
- SwiftUI - Forms
- SwiftUI - Breaking Forms in Sections
- SwiftUI - Event Handling
- SwiftUI - Event Handling
- SwiftUI - Gesture
- SwiftUI - Clipboard
- SwiftUI - Drag and Drop
- SwiftUI - Focus
- SwiftUI - Alert
- SwiftUI - Miscellaneous
- SwiftUI - Containers
- SwiftUI - Navigation
- SwiftUI - Notifications
- SwiftUI - Cross-Platform UI
- SwiftUI - Data
- SwiftUI - Accessibility
- SwiftUI - Framework Integration
- SwiftUI - Framework Integration
- SwiftUI - Interfacing with UIKit
- SwiftUI - Creating macOS App
- SwiftUI Useful Resources
- SwiftUI - Useful Resources
- SwiftUI - Discussion
SwiftUI - Effects
Effects are known as visual modifications or transformations applied to the view to customize the appearance or behavior of the view. They only enhance the visual appearance of the view, not impact the layout because they are not allowed to modify the layout of the view.
Using these effects we can apply various effects like shadow, blurs, rotation, saturation, hue, etc to any view or component such as Text, Image, Shape, Button, etc. They enhance the user experience by improving the readability of the content or can create interactive components.
Applying Effects in SwiftUI
SwiftUI support a wide range of pre-defined modifiers such as shadow, hover, blur, etc, that can use to enhance the appearance of the view. So simply by using these modifiers, we can apply effects on the views. We can use these modifiers directly with the help of the dot operator, for example −
Text("TutorialsPoint").blur(radius:12)
Example 1
The following SwiftUI program is used to apply the blur effect on the text view.
import SwiftUI struct ContentView: View { var body: some View { VStack { // Without any effect Text("TutorialsPoint").font(.largeTitle).foregroundStyle(.green) // With blur effect Text("TutorialsPoint") .font(.largeTitle) .foregroundStyle(.green) .blur(radius: 4) }.padding() } } #Preview { ContentView() }
Output

Example 2
The following SwiftUI program is used to apply multiple effects on the text view.
import SwiftUI struct ContentView: View { var body: some View { VStack { // Without any effect Text("TutorialsPoint").font(.largeTitle).foregroundStyle(.green) // With multiple effects Text("TutorialsPoint") .foregroundStyle(.green) .padding(20) .shadow(radius: 5) .rotationEffect(.degrees(10)) .scaleEffect(2.3) }.padding() } } #Preview { ContentView() }
Output

Types of Effects in SwiftUI
SwiftUI supports the following types of effect−
S.No | Effect | Description |
---|---|---|
1 | scaleEffect() | It is used to increase or decrease the size(horizontally and vertically) of the view. |
2 | rotationEffect() | It is used to rotate the view around the given point in a two-dimensional plane. |
3 | tansformEffect() | It is used to apply an affine transformation to the given view. Affine transformation includes rotation, scaling, translation or skew of the view. |
4 | blur() | It is used to apply Gaussian blur to the specified view. |
5 | shadow() | It is used to apply a shadow effect on the specified view. |
6 | blendMode() | It is used to blend two overlapping views. |
7 | hoverEffect() | It is used to apply hover effect on the specified view. |
8 | colorEffect() | It is used to apply a filter effect on each pixel of the color. |
9 | distortionEffect() | It is used to apply geometric distortion effect on each pixel of the given view. |
10 | layerEffect() | It is used to apply a combination of filters on the raster layer of the view. |
11 | visualEffect() | It is used to apply animatable visual effects by accessing the layout details of the view using a geometry proxy. |
12 | adjustColorEffect() | It is used to apply basic color effects to the view such as saturation, brightness, contrast, hueRotation, and colorMultiply. |