Post

Replies

Boosts

Views

Activity

Reply to UIButtonConfiguration Help
Here's a link to the code I'm trying to work with https://source.chromium.org/chromium/chromium/src/+/main:ios/chrome/browser/ui/price_notifications/cells/price_notifications_track_button.mm;l=26-61?q=price_notifications_track_button. Specifically, I'm trying to deprecate the legacy UIButton system and replace it with UIButtonConfiguration.
Apr ’23
Reply to UIButtonConfiguration Help
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
Apr ’23
Reply to UIButtonConfiguration Help
Also I'm having an issue with this code UIButton *mixedButton = [UIButton buttonWithType:UIButtonTypeSystem]; [self updateButton:mixedButton withFloat:420]; mixedButton.configuration = [UIButtonConfiguration plainButtonConfiguration]; [mixedButton setImage:[UIImage imageNamed:@"Tweet"] forState:UIControlStateNormal]; mixedButton.tintColor = [UIColor redColor]; [self.view addSubview:mixedButton]; How come the tint color doesn't affect the image set when there's a configuration set? From what I read, old methods and properties should override configuration changes.
Apr ’23
Reply to Using UIButtonConfiguration, what is the equivalent to using UIButton.imageEdgeInsets
Thanks for answering! I have another question, In this code https://source.chromium.org/chromium/chromium/src/+/main:ios/chrome/browser/ui/autofill/form_input_accessory/branding_view_controller.mm;l=141?q=branding_view_controller, the image associated (the first logo above the keyboard) looks bigger. Would you happen to know possible reasons why the scaling would be different? I already checked the image scale and size and found that they were 3 and 24x24 respectively. So not sure why when using UIButtonConfiguration the scale looks like 3 but without UIButtonConfiguration the scale looks like 2 but says 3.
May ’23