You can make views disappear after some delay by utilizing the DispatchQueue to schedule async work after some amount of time which toggles a boolean value to make a view appear or disappear.
Author Archives: Paul Young-Suk Lee
How to set the size of SF Symbols in SwiftUI?
Because SF Symbols are similar to fonts you can set the size directly with the .font modifier and passing in a size.
How to present a modal view with Sheet in SwiftUI
A modal view is known as a Sheet in SwiftUI. You can use the method on views to open up a sheet on top of the view it’s attached on by passing in a boolean variable binding, optionally a closure to run when dismissed and the view to show in the modal.
How to use Picker in SwiftUI?
Using the Picker struct you can build out your own view to let users select from a set of items by passing in a label, variable to bind the selection, and the data and views to compute from e.g. content.
How to rotate views in SwiftUI?
You can rotate views by some number of degrees using the .rotationEffect method.
How to create a Button in SwiftUI?
You can use the built-in Button struct to create tappable buttons in SwiftUI. Each Button takes in an action to fire e.g. printing to the console, and a View to render for the button (like a Text() field!).
How to detect finger drags with SwiftUI
You can detect a dragging motion in SwiftUI with DragGesture and passing it into the .gesture modifier.
How to animate Views in SwiftUI?
SwiftUI comes with an .animation modifier that can be applied to any View that conforms to the Animatable property. This includes all Shape like Circle. You can use it by applying the .animation modifier to any of these views with the default being an ease in/ease out animation.
How to create a half circle in SwiftUI?
You can use the built-in .trim() modifier in SwiftUI to create parts of Shape! The .trim() modifier takes two parameters from: and to: which take in CGFloat.
How do you create a Circle in SwiftUI?
SwiftUI comes with a convenient Circle() method to create a Circle for you. All you have to do is define it and that’s it!