Even in this example of a sample project
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.view setBackgroundColor:[UIColor whiteColor]];
UIButton *legacyButton = [[UIButton alloc] init];
[self updateButton:legacyButton withFloat:210];
[self.view addSubview:legacyButton];
UIButtonConfiguration* buttonConfiguration = [UIButtonConfiguration plainButtonConfiguration];
UIButton *configButton = [UIButton buttonWithConfiguration:buttonConfiguration primaryAction:nil];
[self updateButton:configButton withFloat:260];
[self.view addSubview:configButton];
UIButton *mixedButton = [[UIButton alloc] init];
[self updateButton:mixedButton withFloat:310];
mixedButton.configuration = [UIButtonConfiguration plainButtonConfiguration];
[self.view addSubview:mixedButton];
}
- (void) updateButton:(UIButton*)button withFloat: (CGFloat)yAxis {
button.titleLabel.font =
[[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]
fontWithSize:17.0];
[button setBackgroundColor:[UIColor blueColor]];
[button setTitle:@"Legacy" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, yAxis, 160.0, 40.0);
}
@end
You will notice that the UILabel doesn't respect the boundaries of the UIButton. Please help