UILabel+Extension.swift 647 B

12345678910111213141516171819202122232425262728
  1. //
  2. // UILabel+Extension.swift
  3. // MTP2_iOS
  4. //
  5. // Created by zhongyuan on 2018/4/28.
  6. // Copyright © 2018年 zhongyuan.All rights reserved.
  7. //
  8. import Foundation
  9. import UIKit
  10. extension UILabel {
  11. /// 便利构造方法
  12. ///
  13. /// - Parameters:
  14. /// - text: 标签内容
  15. /// - fontSize: 字体大小
  16. /// - color: 字体颜色
  17. convenience init(text: String, fontSize: CGFloat = 14, color: UIColor = UIColor.black) {
  18. self.init()
  19. self.text = text
  20. self.font = UIFont.systemFont(ofSize: fontSize)
  21. self.textColor = color
  22. self.numberOfLines = 0
  23. self.sizeToFit()
  24. }
  25. }