CSMButton.swift 1.05 KB
//
//  CSMButton.swift
//  SwiftWarplyFramework
//
//  Created by Manos Chorianopoulos on 20/9/22.
//

import UIKit

// @IBDesignable
@objc public class CSMButton: UIButton {
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        configure()
    }
    override init(frame: CGRect = .zero) {
        super.init(frame: frame)
        configure()
    }
    
    public override func prepareForInterfaceBuilder() {
        super.prepareForInterfaceBuilder()
        configure()
    }
}

private extension CSMButton {
    func configure() {
        setImage(UIImage(named: "ic_directions", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
        titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
        setTitleColor(.white, for: .normal)
        backgroundColor = UIColor(rgb: 0x79BF14)
        layer.cornerRadius = 12.0
        
        imageEdgeInsets = UIEdgeInsets(top:0.0, left:0.0, bottom:0.0, right:5.0);
        titleEdgeInsets = UIEdgeInsets(top:0.0, left:5.0, bottom:0.0, right:0.0);
    }
}