iOS uses Xib custom UIView

Source: Internet
Author: User

For complex interfaces, customizing UIView with Code is a pain, so you can use Xib to lay it out.

The approximate steps are as follows:

1. Create a new class in your project and inherit the UIView;

2. Create a new XIB(the name of the XIB is the same as the new class name);

3. In Xib, select the class name that you built for the view change class;

4. To use this uiview is not the same as usual. becausenot us.instantiate it. KeyiUse this static method to instantiate

Of. In this static method, the required parameters are passed.

+ (Lktextview *) Instancetextview {nsarray* Nibview = [[NSBundle mainbundle] loadnibnamed:@ "Lktextview" Owner:nil op      Tions:nil];  return [Nibview objectatindex:0]; }
    1. 5. This uiview can be initialized in Viewcontroller, using it.


Reference blog:http://blog.sina.com.cn/s/blog_637a6d510101dq1l.html


This article is from the "Sheep" blog, please make sure to keep this source http://5934497.blog.51cto.com/5924497/1642024

iOS uses Xib custom UIView

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.