UIActionSheet/UIAlertController multiline text

前端 未结 4 1205
孤城傲影
孤城傲影 2021-01-13 05:34

This is the code I am writing to display UIActionSheet.

actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@\"updateresponse         


        
相关标签:
4条回答
  • 2021-01-13 05:45

    This seems to work in iOS 10 and Swift 3.1:

    UILabel.appearance(whenContainedInInstancesOf: [UIAlertController.self]).numberOfLines = 2
    
    0 讨论(0)
  • 2021-01-13 05:46

    This is not possible with the standard UIAlertController or UIAlertView. I would recommend you to make it shorter. Why don't you make an alert and type something like this:

    Do you want to update the response only for this instance or for all activities in this series.

    The answers would be these:

    • Only this instance
    • All activities
    0 讨论(0)
  • 2021-01-13 05:46

    try this

    let alert = UIAlertController(title: title,
                                  message: "you message go here",
                                  preferredStyle: 
    UIAlertControllerStyle.alert)
    
    let cancelAction = UIAlertAction(title: "Cancel",
                                     style: .cancel, handler: nil)
    
    alert.addAction(cancelAction)
    self.present(alert, animated: true, completion: nil)
    
    UILabel.appearance(whenContainedInInstancesOf: 
    [UIAlertController.self]).numberOfLines = 0
    
    UILabel.appearance(whenContainedInInstancesOf: 
    [UIAlertController.self]).lineBreakMode = .byWordWrapping
    
    0 讨论(0)
  • 2021-01-13 06:08

    In iOS 10:

    If you want to apply it to all UIAlertController, you can use these lines of code:

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

    put this in didFinishLaunchingWithOptions method of the AppDelegate.

    0 讨论(0)
提交回复
热议问题