/** * 当控件不是从xib、storyboard中创建时,就会调用这个方法 */ - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self setup]; } return self; } /** * 当控件是从xib、storyboard中创建时,就会调用这个方法 */ - (id)initWithCoder:(NSCoder *)decoder { if (self = [super initWithCoder:decoder]) { [self setup]; } return self; } - (void)setup { self.titleLabel.font = [UIFont systemFontOfSize:32]; } /** * 这个方法在initWithCoder:方法后调用 */ - (void)awakeFromNib { }