【问题标题】:Swift 3 - alert style [duplicate]Swift 3 - 警报样式
【发布时间】:2017-07-11 09:14:55
【问题描述】:

我的项目中有一个alertalert 和其他警报一样简单。我想更改font style and color。这怎么可能?

提前致谢!

【问题讨论】:

    标签: ios swift3 alert


    【解决方案1】:
    let attributedString = NSAttributedString(string: "YourTitle", attributes: [
        NSFontAttributeName : UIFont.systemFontOfSize(18), //your font here
        NSForegroundColorAttributeName : UIColor.black()
    ])
    let alert = UIAlertController(title: "TextTitle", message: "YourMessage",  preferredStyle: .Alert)
    
    alert.setValue(attributedString, forKey: "attributedTitle")
    let cancelAction = UIAlertAction(title: "Cancel",
    style: .Default) { (action: UIAlertAction!) -> Void in
    }
    
    presentViewController(alert,
    animated: true,
    completion: nil)
    

    【讨论】:

      【解决方案2】:

      您可以使用 SweetAlert

      SweetAlert().showAlert("Here's a message!", subTitle: "It's pretty, isn't it?", style: AlertStyle.None)
      

      完整文档和实现链接:https://github.com/codestergit/SweetAlert-iOS

      【讨论】:

        猜你喜欢
        • 2018-01-07
        • 1970-01-01
        • 2013-06-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-05-23
        • 1970-01-01
        相关资源
        最近更新 更多