Ios-xib (using Xib to implement nested custom views)

Source: Internet
Author: User

Reference: Http://wtlucky.github.io/geekerprobe/blog/2014/08/10/nested-xib-views/?utm_source=tuicool

Because the main practice xib is to use xib on the way

1. First create a custom view class

2. Clear the View link (skip this step) to ensure that the above format

3. Create a new link

Add a new link here

This is dragging past, you know ~

4. In Customview.m re-view-(ID) Initwithcoder: (Nscoder *) Adecoder method, let him and xib link up

- (ID) Initwithcoder: (Nscoder *) adecoder{if(self =[Super Initwithcoder:adecoder]) {UIView*containerview = [[[Uinib Nibwithnibname:@"CustomView"Bundle:nil] instantiatewithowner:self Options:nil] Objectatindex:0]; CGRect Newframe= CGRectMake (0,0, $, $); Containerview.frame=Newframe;    [Self addsubview:containerview]; }    returnSelf ;}

Effect Show:

I dragged two view to link them to CustomView.

This is the view I've customized with Xib.

The final display on the simulator: (No automatic layout haha ~ color I do not)

If you want to listen to a different custom control setting the tag value is OK, and then you take this as a system control like drag the same action, the amount seems to customize the control set the color in the back of the bad, I have to make the default.

Ios-xib (using Xib to implement nested custom views)

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.