自定义控件的初始化方法

//通过代码调用

- (id)initWithFrame:(CGRect)frame

{

    self = [super initWithFrame:frame];

    if (self) {

        [self commonInit]; 

    }

    return self;

}

//通过xib调用

- (id)initWithCoder:(NSCoder*)coder

{

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

        [self commonInit];

    }

    return self;

}

- (void)commonInit

{

}

你可能感兴趣的:(自定义控件的初始化方法)