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)