Skip to content

Instantly share code, notes, and snippets.

@RustemAqtau
Last active July 6, 2020 05:33
Show Gist options
  • Save RustemAqtau/073bbc0a2b392f5369b4e2d406b8e285 to your computer and use it in GitHub Desktop.
Save RustemAqtau/073bbc0a2b392f5369b4e2d406b8e285 to your computer and use it in GitHub Desktop.
Extension UIButton
extension UIButton {
convenience init(title: String,
backgroundColor: UIColor,
font: UIFont?,
isShadow: Bool,
cornerRadius: CGFloat
titleColor: UIColor) {
self.init(type: .system) //инициализатор через type
//входные встроенные функции:
self.setTitle(title, for: .normal)
self.setTitleColor(titleColor, for: .normal)
self.backgroundColor = backgroundColor
self.titleLabel?.font = font
self.layer.cornerRadius = cornerRadius
if isShadow {
self.layer.cornerRadius = UIColor.black.cgColor
self.layer.shadowradius = 4
self.layer.shadowOpacity = 0.2
self.layer.shadowOpacity = CGSize(width: 0, height: 4)
}
}
import UIKit
class ViewController: UIViewController {
let emailButton = UIButton(title: "Email", titleColor: .black .....)
let loginButton = UIButton(title: "Email", titleColor: .black .....)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment