| 12345678910111213141516171819202122232425262728293031 |
- //
- // UIButton+Extension.swift
- // MTP2_iOS
- //
- // Created by zhongyuan on 2018/4/28.
- // Copyright © 2018年 zhongyuan.All rights reserved.
- //
- import Foundation
- import UIKit
- extension UIButton {
-
- /// 便利构造方法
- ///
- /// - Parameters:
- /// - title: 标题
- /// - fontSize: 字体大小
- /// - imageName: 显示图片名
- convenience init(title: String,fontSize: CGFloat = 14,normalColor: UIColor = UIColor.black, highlightedColor: UIColor = UIColor.darkGray, imageName: String? = nil) {
- self.init()
- self.setTitle(title, for: .normal)
- self.setTitleColor(normalColor, for: .normal)
- self.setTitleColor(highlightedColor, for: .highlighted)
- self.titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
- if imageName != nil {
- self.setImage(UIImage(named: imageName!), for: .normal)
- }
- self.sizeToFit()
- }
- }
|