How to delete blank view of iOS11 application view in iOS11 development
Editor to share with you how to delete the blank view of the iOS11 application view in iOS11 development. I hope you will get something after reading this article. Let's discuss it together.
When the developer no longer needs a view of the main view, it can be deleted. To do this, you need to use the removeFromSuperview () method, which has the following syntax:
The name of the view object to delete .removeFromSuperview ()
[example 1-3] the following code adds two views to the main view, and then deletes one of them using the removeFromSuperview () method. The code is as follows:
Import UIKit
Class ViewController: UIViewController {
Override func viewDidLoad () {
Super.viewDidLoad ()
/ / Do any additional setup after loading the view, typically from a nib.
/ / add blank view newView1
Let newView1=UIView (frame: CGRect (x: 0, y: 75, width: 375, height: 232))
NewView1.backgroundColor=UIColor.cyan
Self.view.addSubview (newView1)
/ / add blank view newView2
Let newView2=UIView (frame: CGRect (x: 0,352, width: 375, height: 232)
NewView2.backgroundColor=UIColor.orange
Self.view.addSubview (newView2)
}
……
}
When you run the program at this point, you will see the effect shown in figure 1.54. If you want to delete the view object newView1, you need to use the removeFromSuperview () method, as follows:
NewView1.removeFromSuperview () / / Delete the view object newView1
The running effect is shown in figure 1.55.
Figure 1.54 running effect figure 1.55 running effect
After reading this article, I believe you have a certain understanding of "how to delete the blank view of the iOS11 application view in iOS11 development". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!