Skip to content

Instantly share code, notes, and snippets.

@ashutoshbilla
ashutoshbilla / MyUserDefaults.swift
Created October 12, 2019 07:32
Access UserDefaults with getter and setter
struct MyUserDefaults {
// UserDefault value to check if user is logged in
static var isUserLoggedIn: Bool {
get {
return UserDefaults.standard.bool(forKey: MyUserDefaults.Keys.isUserLoggedIn)
}
set {
UserDefaults.standard.set(newValue, forKey: MyUserDefaults.Keys.isUserLoggedIn)
}
}
@ashutoshbilla
ashutoshbilla / StatusBar.swift
Created October 12, 2019 07:18
How to change color or hide status bar in iOS?
// Do not forget to add this to your Info.plist file
// <key>UIViewControllerBasedStatusBarAppearance</key>
// <true/>
// Without UINavigationController
// Use this if you use ViewController as root without a UINavigationController
class ViewController: UIViewController {
override var prefersStatusBarHidden: Bool {