Dimitris Togias

optimize csm button

...@@ -9,21 +9,31 @@ import UIKit ...@@ -9,21 +9,31 @@ import UIKit
9 9
10 @IBDesignable 10 @IBDesignable
11 class CSMButton: UIButton { 11 class CSMButton: UIButton {
12 -
13 - required init() {
14 - super.init(frame: .zero)
15 - self.setup()
16 - }
17 -
18 required init?(coder aDecoder: NSCoder) { 12 required init?(coder aDecoder: NSCoder) {
19 super.init(coder: aDecoder) 13 super.init(coder: aDecoder)
20 - self.setup() 14 + configure()
15 + }
16 +
17 + override init(frame: CGRect = .zero) {
18 + super.init(frame: frame)
19 + configure()
21 } 20 }
22 21
23 - private func setup() { 22 + override func prepareForInterfaceBuilder() {
24 - self.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16) 23 + super.prepareForInterfaceBuilder()
25 - self.setTitleColor(.white, for: .normal) 24 + configure()
26 - self.backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00) 25 + }
27 - self.layer.cornerRadius = 12.0 26 +}
27 +
28 +private extension CSMButton {
29 + func configure() {
30 + setImage(UIImage(named: "directions"), for: .normal)
31 + titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16)
32 + setTitleColor(.white, for: .normal)
33 + backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00)
34 + layer.cornerRadius = 12.0
35 +
36 + imageEdgeInsets = UIEdgeInsets(top:0.0, left:0.0, bottom:0.0, right:5.0);
37 + titleEdgeInsets = UIEdgeInsets(top:0.0, left:5.0, bottom:0.0, right:0.0);
28 } 38 }
29 } 39 }
......
...@@ -187,6 +187,11 @@ ...@@ -187,6 +187,11 @@
187 <point key="canvasLocation" x="137.68115942028987" y="120.53571428571428"/> 187 <point key="canvasLocation" x="137.68115942028987" y="120.53571428571428"/>
188 </view> 188 </view>
189 </objects> 189 </objects>
190 + <designables>
191 + <designable name="bw3-J9-wHr">
192 + <size key="intrinsicContentSize" width="67" height="31"/>
193 + </designable>
194 + </designables>
190 <resources> 195 <resources>
191 <systemColor name="systemBackgroundColor"> 196 <systemColor name="systemBackgroundColor">
192 <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> 197 <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
......