-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCustomButton.swift
18 lines (17 loc) · 1.04 KB
/
CustomButton.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import Foundation
import UIKit
class CustomButton: UIButton {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
let widthContraints = NSLayoutConstraint(item: self, attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 100)
let heightContraints = NSLayoutConstraint(item: self, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 100)
NSLayoutConstraint.activate([heightContraints,widthContraints])
//let rect = CGRect(origin: self.frame.origin, size: CGSize(width: 100, height: 100))
//self.frame = rect
self.layer.cornerRadius = 50
self.backgroundColor = UIColor.white
self.layer.borderWidth = 4
self.layer.borderColor = UIColor.red.cgColor
self.setTitle("", for: .normal)
}
}