objective c - Constraints programatically and with Storyboards -
it possible set constraints programmatically , while using storyboards? using https://github.com/raphaelschaad/rsplaypausebutton constraints https://github.com/snapkit/masonry. not being displayed correctly:
the image on left not being displayed correctly, , not clickable (it button).
relevant code:
- (void)viewdidload { [super viewdidload]; _playpausebutton = [[rsplaypausebutton alloc] init]; _playpausebutton.tintcolor = [uicolor blackcolor]; [_playpausebutton addtarget:self action:@selector(playpausebuttondidpress:) forcontrolevents:uicontroleventtouchupinside]; [self.view addsubview:_playpausebutton]; } - (void)viewdidlayoutsubviews { [self.playpausebutton mas_makeconstraints:^(masconstraintmaker *make) { make.center.equalto(self.view).with.offset(10); }]; }
you need adding width/height constraints playpausebutton
, try this:
- (void)viewdidload { [super viewdidload]; _playpausebutton = [[rsplaypausebutton alloc] init]; _playpausebutton.tintcolor = [uicolor blackcolor]; [_playpausebutton addtarget:self action:@selector(playpausebuttondidpress:) forcontrolevents:uicontroleventtouchupinside]; [self.view addsubview:_playpausebutton]; [playpausebutton mas_makeconstraints:^(masconstraintmaker *make) { make.center.equalto(self.view).with.offset(10); make.width.equalto(@(50)); make.height.equalto(@(50)); }]; }
Comments
Post a Comment