ios创建自定义控件必须具备的三个方法

1、当用代码创建控件时调用

-(instancetype)initWithFrame:(CGRect)frame

{

    if (self = [super initWithFrame:frame]) {

        [self setub];

    }

    return self;

}

2、当用storyboard或者是xib或者文件 创建时调用

-(id)initWithCoder:(NSCoder *)aDecoder

{

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

        [self setub];

    }

    return self;

}

3、初始化方法

-(void)setub{

    

}

原文地址:https://www.cnblogs.com/nianzhilian/p/4928583.html