iOS development Storyboard Set rounded buttons

Source: Internet
Author: User

1. Many people know that it is common to set a button to the other uiview of the sub-class, you need to use the following statement

<span style= "FONT-FAMILY:SIMSUN;FONT-SIZE:18PX;" >self.button.layer.cornerradius=10;//</span>
<span style= "FONT-FAMILY:SIMSUN;FONT-SIZE:18PX;" ></span>

Note: This is implemented with the properties of the layer layers, because in a uiview subclass,

UIView itself is only used to listen to events, and the real content is the layer layers, which of course also contains the implementation of animation, such as we do to a view animation

is actually the animation of the layer;

2. However, there are always curious people who want to know how to pass, Storyboard/xib set a button or UIView fillet:
Through my research, I found a powerful way to set properties that Storybord cannot add, such as rounded corners, or borders

This method is runtime attribute runtime properties, that is, at run time you set this property will work, which embodies the OC language dynamic characteristics and runtime (runtime) of the powerful

Create a button and then set the constraint (so that the button "disappears"), such as, and then select the button to select the right inspector


For example, click on the + sign to add a button-related property, which can be a property that is not on the storyboard, this method is similar to the effect of the code, each property has a corresponding value (object),

If the number corresponds to a value type of nsnumber, such as, fill in the runtime Attrite in the property name do not write wrong, otherwise the runtime will crash


Finally, you can see the rounded corners you want on the simulator.

3. Similar you can add other properties of the button





iOS development Storyboard Set rounded buttons

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.