我有一个操作表“selectedActionSheet”。我使用 actionsheet
alertcontroller
UIAlertController *alertController = [selectedActionSheet valueForKey:@"_alertController"];
现在,我按如下方式更改色调颜色:
if ([alertController isKindOfClass:[UIAlertController class]])
{
alertController.view.tintColor = [UIColor colorWithRed:0.0/255.0 green:99.0/255.0 blue:65.0/255.0 alpha:1.0];
}
这会改变色调的颜色,但是当我单击操作表时,我再次看到默认的蓝色。有人可以帮我解决这个问题吗?我是 Objective c 的新手。
最佳答案
只需在 presentViewController
之后设置 alertController
tintColor
即
[self presentViewController:alertController animated:YES completion:nil];
alertController.view.tintColor = [UIColor colorWithRed:0.0/255.0 green:99.0/255.0 blue:65.0/255.0 alpha:1.0];
这将更改默认值和突出显示的颜色。希望这能解决您的问题。
如果你只是想呈现 actionSheet,那么请尝试下面的代码-
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Hello Dear" message:@"I'm an actionSheet!" preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action){
//add code to make something happen once tapped
}];
[alertController addAction: ok];
UIAlertAction *Cancel = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action){
//add code to make something happen once tapped
}];
[alertController addAction: Cancel];
[self presentViewController:alertController animated:YES completion:nil];
alertController.view.tintColor = [UIColor colorWithRed:0.0/255.0 green:99.0/255.0 blue:65.0/255.0 alpha:1.0];
actionSheet 看起来像这样-
关于ios - 如何更改 objective-c 中的字体样式和颜色或操作表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38320039/