I need advice how to proceed.
How to slightly dim the main view and display some busy indicator, for the duration of of some action, and then remove the dimming?
In Swift language.
Thanks!
UPD: In Objective-C I use earlier something like this:
UIView *dimView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
dimView.backgroundColor = [UIColor blackColor];
dimView.alpha = 0.5f;
dimView.tag = 1111;
dimView.userInteractionEnabled = NO;
[self.view addSubview:dimView];
How this code we can do it in Swift?
Adds a view to the end of the receiver's list of subviews.
How To Add, Insert, Move, Remove Sub View In iOS Swift 1 Manage Swift View And Subview Example Demo. First let us look at this example in a video as below. ... 2 Manage Swift Subview Functions Introduction. parentViewObject.addSubview ( subView : UIView ) : Add a subview to parent view. ... 3 Manage Swift Subview Example Source Code.
One of the cool things that are wrapped into navigation links is that Swift UI automatically adds a back button on the secondary view and will know to navigate back to the previous view when selected. Navigation links make connecting views a breeze with Swift UI!
Today, we’re going to add a NavigationView to our List and implement a detail view for each row in the List using NavigationLink. First, we need to embed our List in NavigationView and set its title using navigationBarTitle modifier. Entire code for the List should look like this:
The List has a large title and with each row having a navigation arrow indicating that the user can tap on it to push a detail view.
Do as follows, I have checked, working fine in Swift
We have have to initialize the view with the frame and then we have to set the .alpha
property for dim the view.
let testFrame = CGRect(x: 0, y: 100, width: 100, height: 100)
var testView : UIView = UIView(frame: testFrame)
testView.backgroundColor = UIColor(red: 0.5, green: 0.5, blue: 0.5, alpha: 1.0)
testView.alpha=0.5
self.view.addSubview(testView)
And .addSubview
will add the view inside the main view.
Happy Coding :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With