UIButton+Extension.swift 843 B

1234567891011121314151617181920212223242526
  1. //
  2. // UIButton+Extension.swift
  3. // o2app
  4. //
  5. // Created by 刘振兴 on 2017/8/25.
  6. // Copyright © 2017年 zone. All rights reserved.
  7. //
  8. import UIKit
  9. extension UIButton {
  10. class func btn(bgColor: UIColor, disabledColor: UIColor, title: String, titleColor: UIColor) -> UIButton {
  11. let btn = UIButton(type: .custom)
  12. btn.frame = .zero
  13. let attribeTitle = NSAttributedString(string: title, attributes: [NSAttributedString.Key.foregroundColor:titleColor,NSAttributedString.Key.font:UIFont.init(name: "PingFangSC-Regular", size: 18)!])
  14. btn.setAttributedTitle(attribeTitle, for: .normal)
  15. btn.setAttributedTitle(attribeTitle, for: .disabled)
  16. btn.backgroundColor = bgColor
  17. btn.layer.cornerRadius = 3.0
  18. btn.layer.masksToBounds = true
  19. return btn
  20. }
  21. }