2014-10-16 55 views
0

我有一個iPad應用程序,其已經適用於iOS 7.我用於減少在動作片按鈕上的文本大小與此代碼:目標C - 在動作表變更文字尺寸爲iOS 8

- (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上使用UIAlertControllerUIAlertAction的方法。儘管UIAlertController具有子視圖的視圖,但其中似乎沒有任何UIButtonUILabel

+0

你不能在iOS 8中做到這一點。它是完全不同的。更好地糾正你自己的錯誤或者找到允許定製的第三方'UIActionSheet'替代品。 – rmaddy 2014-10-16 23:30:35

+0

是的,我最終創建了一個視圖控制器,其中包含一個彈出控制器中的單個按鈕。謝謝。 – calvillo 2014-10-17 14:09:22

+0

這個答案也可以幫助你:http://stackoverflow.com/a/26463892/3219089 – Ivan 2014-10-20 12:26:51

回答

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 
+0

我不確定這是否行得通,因爲我相信'UIAlertController'沒有'UILabel',但我會試一試。 – calvillo 2014-10-22 16:06:17

+0

你有什麼成就嗎?爲我工作 – f3n1kc 2014-10-28 20:37:00