UIAlertController (ActionSheet) 在设置 tintColor 后改变形状
UIAlertController (ActionSheet) changes shape after setting tintColor
我的 UIAlertController
具有首选样式 ActionSheet
运行良好,没有任何问题。为了防止冗长的代码墙,我删除了 UIAlertAction
闭包中的操作并添加了代码:
let alert = UIAlertController(title: "More actions", message: nil, preferredStyle: .ActionSheet)
//alert.view.tintColor = UIColor(red: CGFloat(252.0/255.0), green: CGFloat(112.0/255.0), blue: CGFloat(87.0/255.0), alpha: 1.0)
alert.addAction(UIAlertAction(title: "Rename", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Move", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Keep offline", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
此代码运行良好,结果如下:
但是 当我取消注释我设置 tintColor
的行时,我失去了 .Default
按钮和 [=16] 之间的间隙=] 按钮:
有没有办法防止这种情况发生,或者这是我忽略了一些小细节的结果?
将按钮添加到警报控制器后设置色调似乎可行:
let alert = UIAlertController(title: "More actions", message: nil, preferredStyle: .ActionSheet)
alert.addAction(UIAlertAction(title: "Rename", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Move", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Keep offline", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
alert.view.tintColor = UIColor(red: CGFloat(252.0/255.0), green: CGFloat(112.0/255.0), blue: CGFloat(87.0/255.0), alpha: 1.0)
self.presentViewController(alert, animated: true, completion: nil)
需要在设置样式后设置警报视图色调。
我的 UIAlertController
具有首选样式 ActionSheet
运行良好,没有任何问题。为了防止冗长的代码墙,我删除了 UIAlertAction
闭包中的操作并添加了代码:
let alert = UIAlertController(title: "More actions", message: nil, preferredStyle: .ActionSheet)
//alert.view.tintColor = UIColor(red: CGFloat(252.0/255.0), green: CGFloat(112.0/255.0), blue: CGFloat(87.0/255.0), alpha: 1.0)
alert.addAction(UIAlertAction(title: "Rename", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Move", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Keep offline", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
此代码运行良好,结果如下:
但是 当我取消注释我设置 tintColor
的行时,我失去了 .Default
按钮和 [=16] 之间的间隙=] 按钮:
有没有办法防止这种情况发生,或者这是我忽略了一些小细节的结果?
将按钮添加到警报控制器后设置色调似乎可行:
let alert = UIAlertController(title: "More actions", message: nil, preferredStyle: .ActionSheet)
alert.addAction(UIAlertAction(title: "Rename", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Move", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Keep offline", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
alert.view.tintColor = UIColor(red: CGFloat(252.0/255.0), green: CGFloat(112.0/255.0), blue: CGFloat(87.0/255.0), alpha: 1.0)
self.presentViewController(alert, animated: true, completion: nil)
需要在设置样式后设置警报视图色调。