0

I have an iPad app which already works on iOS 7. I used to reduce the text size in the action sheet buttons with this code:

- (void) willPresentActionSheet:(UIActionSheet *)actionSheet {
  for (UIView *subview in actionSheet.subviews) {
    if ([subview isKindOfClass:[UIButton class]]) {
      UIButton *button = (UIButton *)subview;
      button.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:17.0];
    }
  }
}

I'm looking for a way to do the same on iOS 8 with UIAlertController and UIAlertAction. Although the UIAlertController has a view with subviews, it doesn't seem to have any UIButton or UILabel in it.

calvillo
  • 892
  • 1
  • 9
  • 23
  • You can't do this in iOS 8. It's all different. Better to right your own or find a 3rd party `UIActionSheet` replacement that allows for customizations. – rmaddy Oct 16 '14 at 23:30
  • Yes, I ended up creating a view controller with a single button inside of a popover controller. Thank you. – calvillo Oct 17 '14 at 14:09
  • This answer may also help you: http://stackoverflow.com/a/26463892/3219089 – Ivan Oct 20 '14 at 12:26

1 Answers1

0

You CAN do that on iOS8. Just subclass UIAlertController, check code below:

@interface AlertController : UIAlertController

@end

@implementation AlertController

- (void)viewWillLayoutSubviews {
  [super viewWillLayoutSubviews];

  // Search for labels and change font
  [self changeLabelsFontInView:self.view];
}

- (void)changeLabelsFontInView:(UIView *)view {
  if (view.subviews.count > 0) {
    for (UIView *subview in view.subviews) {
      [self changeLabelsFontInView:subview];
    }
  } else {
    if ([view isKindOfClass:[UILabel class]]) {
      [(UILabel *)view setFont:[UIFont boldSystemFontOfSize:35.0F]];
    }
  }
}

@end
f3n1kc
  • 2,087
  • 18
  • 18
  • I'm not sure this works because I believe `UIAlertController` has no `UILabel`'s, but I will give it a try. – calvillo Oct 22 '14 at 16:06