Skip to content

Instantly share code, notes, and snippets.

@0xinterface
Last active November 14, 2017 04:22
Show Gist options
  • Save 0xinterface/943f461bf19aec8c2030d6d9bdfa7fd1 to your computer and use it in GitHub Desktop.
Save 0xinterface/943f461bf19aec8c2030d6d9bdfa7fd1 to your computer and use it in GitHub Desktop.
Cheatsheet
var window: UIWindow?
var navigationController: UINavigationController?
var mainViewController: UIViewController?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds)
mainViewController = UIViewController()
navigationController = UINavigationController(rootViewController: mainViewController!)
window?.rootViewController = navigationController
window?.makeKeyAndVisible()
return true
}
extension UIColor {
convenience init(red: Int, green: Int, blue: Int, a: CGFloat = 1.0) {
self.init(
red: CGFloat(red) / 255.0,
green: CGFloat(green) / 255.0,
blue: CGFloat(blue) / 255.0,
alpha: a
)
}
convenience init(rgb: Int, a: CGFloat = 1.0) {
self.init(
red: (rgb >> 16) & 0xFF,
green: (rgb >> 8) & 0xFF,
blue: rgb & 0xFF,
a: a
)
}
}
extension UIButton {
func applyRaisedStyle(){
self.setTitleColor(UIColor.black, for: .normal)
self.backgroundColor = UIColor.white
self.layer.cornerRadius = 6
self.layer.masksToBounds = false
self.layer.shadowColor = UIColor.black.cgColor
self.layer.shadowOffset = CGSize(width: 0, height: 0.08)
self.layer.shadowOpacity = 0.075
self.layer.shadowRadius = 5
self.layer.shadowPath = UIBezierPath(rect: self.bounds).cgPath
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment