Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Is there a uiviewcontroller with blur background in swift?


Asked by Dennis Matthews on Dec 14, 2021 Swift



UIViewController with blur background in Swift — iOS The blur effect is often used in Apple’s official apps. The bad news is that Apple doesn’t provide any native API in the UIViewController Class to implement the blurred background.
Thereof,
You will need to create the blur effect using the UIBlurEffect Class in the viewDidLoad method. After that you’ll need to apply the effect to the UIVisualEffectView. The UIVisualEffectView needs to have the container dimensions defined, and it will be the first view of the stack of the view controller.
One may also ask, How To Set Image As UIView Background. 3.1 Add Image To The Swift Project. First you should get a jpg or png format image. Right click the swift project, click Add Files to “project name” menu item in the popup menu list. Select the image in top file explorer, and select the project name in Add to targets area. Then click Add button.
In respect to this,
Conforming to UIViewControllerRepresentable does require us to implement two methods: one called makeUIViewController (), which is responsible for creating the initial view controller, and another called updateUIViewController (), which is designed to let us update the view controller when some SwiftUI state changes.
Additionally,
If you are presenting this view controller modally to blur the underlying content, you'll need to set the modal presentation style to Over Current Context and set the background color to clear to ensure the underlying view controller will remain visible once this is presented overtop.