解决方法
最后我通过使用UIAlertController得到了答案:
- UIAlertController *customActionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
- UIAlertAction *firstButton = [UIAlertAction actionWithTitle:@"First Button" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- //click action
- }];
- [firstButton setValue:[UIColor blackColor] forKey:@"titleTextColor"];
- [firstButton setValue:[UIColor blackColor] forKey:@"imageTintColor"];
- [firstButton setValue:@true forKey:@"checked"];
- UIAlertAction *secondButton = [UIAlertAction actionWithTitle:@"Second Button" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
- //click action
- }];
- [secondButton setValue:[UIColor blackColor] forKey:@"titleTextColor"];
- UIAlertAction *cancelButton = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){
- //cancel
- }];
- [cancelButton setValue:[UIColor blackColor] forKey:@"titleTextColor"];
- [customActionSheet addAction:firstButton];
- [customActionSheet addAction:secondButton];
- [customActionSheet addAction:cancelButton];
- [self presentViewController:customActionSheet animated:YES completion:nil];
这就是结果: