手记

iOS学习笔记--xib自定义view的注意事项

#import <UIKit/UIKit.h>

@interface TextV : UIView

@end
#import "TextV.h"
@interface TextV ()

@property (strong, nonatomic) IBOutlet UIView *containerView;

@end
@implementation TextV

- (instancetype)initWithCoder:(NSCoder *)aDecoder{

    if (self = [super initWithCoder:aDecoder]) {

        self.containerView = [[[UINib nibWithNibName:NSStringFromClass([self class]) bundle:nil] instantiateWithOwner:self options:nil] lastObject];
        self.containerView.frame = self.bounds;
        [self addSubview:self.containerView];

    }

    return self;
}

-(void)awakeFromNib
{
    [super awakeFromNib];

}

@end

0人推荐
随时随地看视频
慕课网APP