How to set the appearance of buttons in the iOS11 application view beautification button
This article will explain in detail how to set the appearance of the button in the iOS11 application view beautification button. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
To put it bluntly, to beautify the button is to set the properties of the button. There are two ways to set the properties of the button: one is to use the property inspector in the editing interface; the other is to use the code to set it. The following will mainly explain how to use code to set up buttons.
1. Set the appearance of the button
Setting the appearance of the button is actually setting the button's title, image, and so on. Table 2-1 lists some of the properties commonly used to set the appearance of buttons.
Table 2-1 Common attributes
[example 2 # 2] A button will be added to the main view below. The title of this button is I am button, and the color of the title is black. 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 button object
Let button=UIButton (frame: CGRect (x: 135, y: 241, width: 97, height: 30))
Button.setTitle ("I am Button", for: UIControlState.normal) / / set the title
Button.setTitleColor (UIColor.black, for: UIControlState.normal) / / sets the color of the title
Self.view.addSubview (button)
}
……
}
When you run the program at this point, you will see the effect shown in figure 2.3.
Figure 2.3 running effect
This is the end of this article on "how to set the appearance of the button in the iOS11 application view beautification button". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.