CSMButton.swift 1023 Bytes
//
//  CSMButton.swift
//  SwiftWarplyFramework
//
//  Created by Dimitris Togias on 14/9/22.
//

import UIKit

@IBDesignable
class CSMButton: UIButton {
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        configure()
    }

    override init(frame: CGRect = .zero) {
        super.init(frame: frame)
        configure()
    }
    
    override func prepareForInterfaceBuilder() {
        super.prepareForInterfaceBuilder()
        configure()
    }
}

private extension CSMButton {
    func configure() {
        setImage(UIImage(named: "directions"), for: .normal)
        titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16)
        setTitleColor(.white, for: .normal)
        backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00)
        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);
    }
}