2015-10-19 55 views
1

這是我正在編寫的代碼UIActionSheetUIActionSheet/UIAlertController多行文本

actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"updateresponseforrecurring", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil otherButtonTitles: 
        NSLocalizedString(@"updateresponseonlyforthis", nil), 
        NSLocalizedString(@"updateresponseforallactivities", nil), 
        nil]; 
    actionSheet.tag = 2; 
    [actionSheet showInView:[UIApplication sharedApplication].keyWindow]; 

這是我得到使用此:

enter image description here

顯然,第二個選項是較長,因此尺寸變小,以適應寬度。
但我想爲所有選項留下多行的相同字體大小。還嘗試使用UIAlertController,但無法設置多行文字。 如何做到這一點?

回答

2

這是標準UIAlertControllerUIAlertView不可能的。 我會建議你縮短它。你爲什麼不提醒並鍵入如下內容:

是否只想更新此實例或本系列中所有 活動的響應。

的答案會是這些:

  • 只有這種情況下
  • 所有活動
+0

如果我的回答確實幫您解決問題,請選擇它作爲公認的答案。謝謝! –

0

在iOS系統10:

如果您想要應用到所有的UIAlertController,你都可以使用se行代碼:

[[UILabel appearanceWhenContainedIn:[UIAlertController class], nil] setNumberOfLines:2]; 
[[UILabel appearanceWhenContainedIn:[UIAlertController class], nil] setFont:[UIFont systemFontOfSize:9.0]]; 

把它放在了AppDelegate的didFinishLaunchingWithOptions方法中。

11

這似乎在iOS的10和雨燕3.1的工作:

UILabel.appearance(whenContainedInInstancesOf: [UIAlertController.self]).numberOfLines = 2