Skip to content

wanewang/CustomXibOnXib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is demo code to show Your Custom Xib UIView(w/ or w/o autolayout) on another Xib or Storyboard View Controller

The most important UIView base code is inside BaseView or here.

- (void)xibSetup {
#if !TARGET_INTERFACE_BUILDER
    NSBundle *bundle = [NSBundle mainBundle];
#else
    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
#endif
// change nib named string if your xib name not the same as class
    UIView *view = [[bundle loadNibNamed:NSStringFromClass([self class]) owner:self options:nil] firstObject];
    view.frame = self.layer.bounds;
    view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [self addSubview:view];
}

Because showing Xib on another Xib you have to implement initWithFrame with some view setup function. And be aware of the TARGET_INTERFACE_BUILDER, it's a must have bundle init type check method.

###screen shots 1

2

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published