CLAlertController.swift 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // CLAlertController.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2019/12/29.
  6. // Copyright © 2019 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. class CLAlertController: UIAlertController{
  10. override func viewDidLoad() {
  11. super.viewDidLoad()
  12. // let titleStr = "Choose a photo"
  13. // let titleAttrString = NSMutableAttributedString(string: titleStr)
  14. // //to change font of title and message.
  15. // let titleFont = [NSAttributedString.Key.font: UIFont(name: Alibaba_PuHuiTi_Bold, size: 18.0)!]
  16. // let titleColor = [NSAttributedString.Key.foregroundColor: UIColor(hexString: "333333")]
  17. //
  18. // titleAttrString.addAttributes(titleFont, range: NSRange(location: 0, length: titleStr.count))
  19. // titleAttrString.addAttributes(titleColor, range: NSRange(location: 0, length: titleStr.count))
  20. // self.setValue(titleAttrString, forKey: "attributedTitle")
  21. }
  22. override func addAction(_ action: UIAlertAction) {
  23. super.addAction(action)
  24. if action.style == .default {
  25. action.setValue(UIColor(hexString: "333333"), forKey: "titleTextColor")
  26. }else if action.style == .cancel{
  27. action.setValue(UIColor(hexString: "#C6CDD5"), forKey: "titleTextColor")
  28. }
  29. }
  30. }