微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

swift – 如何在UIAlertController中更改一个UIAlertAction文本颜色

如何在UIAlertController中更改一个UIAlertAction的文本颜色,而不是所有操作按钮.

这是我的UIAlertController代码:我想将Delete UIAlertAction文本颜色更改为红色.

//Alert to select more method
func moreAlert()
{           
    let optionMenu = UIAlertController(title: "Mere",message: "",preferredStyle: UIAlertControllerStyle.ActionSheet)

    let Edit = UIAlertAction(title: "Rediger",style: .Default,handler: { action in

    })


    let Delete = UIAlertAction(title: "Slet",handler: { action in

    })

    let cancelAction = UIAlertAction(title: "Annullere",style: .Cancel,handler: { action in        
        print("Cancelled")
    })

    optionMenu.addAction(Edit)            
    optionMenu.addAction(Delete)            
    optionMenu.addAction(cancelAction)


    self.presentViewController(optionMenu,animated: true,completion: nil)
}

解决方法

在Delete UIAlertAction的初始值设定项中使用参数样式:.destructive

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐