This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Before | |
let v1 = UIViewController() | |
v1.title = "View 1" | |
let v2 = UIViewController() | |
v2.title = "View 2" | |
let tabBar = UITabBarController(viewControllers: [v1, v2]) | |
//After |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UITableView { | |
public func register(_ cellClass: Swift.AnyClass) { | |
self.register(cellClass, forCellReuseIdentifier: String(describing: cellClass)) | |
} | |
public func dequeueReusableCell<T: UITableViewCell>() -> T { | |
return self.dequeueReusableCell(withIdentifier: String(describing: T.self)) as! T | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let firstName = UILabel() <== { | |
$0.font = UIFont(name: "AvenirNext-Regular", size: 12)! | |
$0.color = .white | |
} | |
let lastName = UILabel() <== { | |
$0.font = UIFont(name: "AvenirNext-Regular", size: 12)! | |
$0.color = .white | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension UIFont { | |
static func bold(size: CGFloat) -> UIFont { | |
return UIFont(name: "AvenirNext-Bold", size: size)! | |
} | |
static func medium(size: CGFloat) -> UIFont { | |
return UIFont(name: "AvenirNext-Medium", size: size)! | |
} | |
static func regular(size: CGFloat) -> UIFont { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let firstName = UILabel() <== { | |
$0.font = .regular(size: 12) | |
$0.color = .white | |
} | |
let lastName = UILabel() <== { | |
$0.font = .regular(size: 12) | |
$0.color = .white | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension UILabel { | |
func styleText(font: UIFont, color: UIColor, alignment: NSTextAlignment = .left) -> UILabel { | |
return self <== { | |
$0.font = font | |
$0.textColor = color | |
$0.textAlignment = alignment | |
} | |
} | |
func wrapLines(max: Int = 0) -> UILabel { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let firstName = UILabel().styleText(font: .regular(size: 12), color: .white) | |
let lastName = UILabel().styleText(font: .regular(size: 12), color: .white) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension UIButton { | |
func styleText(font: UIFont, color: UIColor) -> UIButton { | |
return self <== { | |
$0.titleLabel?.font = font | |
$0.setTitleColor(color, for: .normal) | |
} | |
} | |
func styleBase() -> UIButton { |
OlderNewer