Custom UIButton with XIB

I know that you can create a custom UITableViewCell with an XIB file and do it, but how can I do this with a button, so create new Lables or something else?

Thank you very much

+4
source share
1 answer

Implement UIButton as follows:

@interface MyNewButton : UIButton{ UILabel* nickNameLabel; UIImageView* myImageView; } @property (nonatomic, retain) UIImageView *myImageView; @property (nonatomic, retain) UILabel* nickNameLabel; @end @implementation MyNewButton @synthesize myImageView; @synthesize nickNameLabel; - (id)initWithFrame:(CGRect)frame { myImageView=[[AXSImageView alloc] initWithFrame:CGRectMake(10, 3, 40, 40)]; [self addSubview:myImageView]; nickNameLabel=[[UILabel alloc] initWithFrame:CGRectMake(myImageView.frame.origin.x + myImageView.frame.size.width + 6, 15, 80, 17)]; [self addSubview:nickNameLabel]; } - (void)drawRect:(CGRect)rect { //DO What You Need } - (void)dealloc { [nickNameLabel release],nickNameLabel=nil; [myImageView release],myImageView=nil; [super dealloc]; } @end 

UIView, which can also be added to this class as a subtitle using an XIB file, you know what that means :)

+1
source

Source: https://habr.com/ru/post/1438263/


All Articles