Fah*_*kar 12 objective-c button uialertview ios
我有alertview,我有Yes和No选项.它看起来像下面.
使用的代码是
UIAlertView *confAl = [[UIAlertView alloc] initWithTitle:@"" message:@"Are you sure?" delegate:self cancelButtonTitle:@"Yes" otherButtonTitles:@"No", nil];
confAl.tag = 888;
[confAl show];
Run Code Online (Sandbox Code Playgroud)
这是完美的但我希望是粗体而不是普通字体.
所以我切换了Yes和No按钮,如下所示.
使用的代码是
UIAlertView *confAl = [[UIAlertView alloc] initWithTitle:@"" message:@"Are you sure?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
confAl.tag = 888;
[confAl show];
Run Code Online (Sandbox Code Playgroud)
有没有什么方法可以让Yes作为第一个按钮而No作为第二个按钮,Yes是否为粗体效果?
注意: 我想在iOS 6(相同的旧样式)和iOS 7(图像中的新样式)中也需要相同的效果.
Sk *_*din 23
您可以使用preferredAction
默认属性UIAlertController
而不是UIAlertView
.
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"alert" message:@"My alert message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* yesButton = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alertController dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* noButton = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alertController dismissViewControllerAnimated:YES completion:nil];
}];
[alertController addAction:noButton];
[alertController addAction:yesButton];
[alertController setPreferredAction:yesButton];
Run Code Online (Sandbox Code Playgroud)
setPreferredAction
将您的按钮标题设置为粗体.
归档时间: |
|
查看次数: |
12368 次 |
最近记录: |