In this part of the custom control, it may be more about the work of the artist than what the programmer should do. But the program does not understand the design of the ape is not a good siege lion. Program apes should also learn a little basic UI design, which will be more conducive to future learning and development.
Here I will take a button as an example to learn how to set the background image and color of this button. As we all know, the buttons in iOS are very concise, usually the blue text represents a button, and a rectangular color block in Android indicates that the button is different. But if you need to customize the background of the buttons in iOS because of the actual application, we can do so with a simple setup.
(1) First in the project to drag into two different colors of the background, one as the default state of the button, a button when clicked under the state of the button. The picture is placed in the images.xcassets.
(2) Drag a button in the interface and select default in the Right state Config, which means that the button is in normal condition and then select a background image in the background below.
。
(3) Then choose highlighted, this means that the highlight, that is, the button is being clicked on the state, and then select a background map.
。
(4) Run the program, the status of the button in normal state and click the following:
。
。
(5) Of course, you will also find that there is selected in State Config, which indicates the status of the display after being clicked; Disable indicates the state when it cannot be clicked. We can try it out separately.
Many other controls have settings that are the same as buttons, and can be customized. There are lots of interesting properties in the property inspector on the right, so you can play with them.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
iOS project development-custom control backgrounds and colors