Code for iOS base control to create controls without storyboard

Source: Internet
Author: User

In the development process, not every time through the storyboard drag control to complete the UI interface, because storyboard above the interface is "fixed dead", and sometimes may be in the process of running the program to dynamically add some new controls to the interface.

such as QQ chat information, is someone sent a message after the dynamic display.

So, you need to know how to dynamically add controls in code. In fact, the essence of storyboard is to turn to the corresponding code according to the graphical interface description.

Practice:

 //  Create a custom button  UIButton *btn = [UIButton Buttonwithtype:uibuttontypecustom];  //  [Btn setbackgroundimage:[uiimage imagenamed:@ " btn_01   "  //  [btn settitle:@ "  dot me   "  Forstate:uicontrolstatenormal];  //  [btn Settitlecolor:[uicolor Redcolor] forstate:uicontrolstatenormal]; 

A few lines of code can be used instead of the same effect as dragging and setting the control property in storyboard

Code for iOS base control to create controls without storyboard

Related Article

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.