我有一个已在iOS 7上运行的iPad应用程序。我曾使用此代码缩小操作表按钮中的文本大小:
- (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];
}
}
}
我正在寻找一种在iOS 8上使用UIAlertController
和UIAlertAction
执行相同操作的方法。虽然UIAlertController
包含子视图的视图,但它似乎没有UIButton
或UILabel
。
答案 0 :(得分:0)
你可以在iOS8上做到这一点。只需将UIAlertController子类化,请检查以下代码:
@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