ytyubox / YuBlog

這是用來記錄的Blog,紀錄內容在 Issues 頁面中。
0 stars 0 forks source link

20190331 setting Bundle 用法 #17

Open ytyubox opened 5 years ago

ytyubox commented 5 years ago
NotificationCenter.default.addObserver(
                                  self,
                                  selector: #selector(appWillEnterForeground),
                                  name: UIApplication.willEnterForegroundNotification,
                                  object: nil)
<dict>
    <key>Type</key>
    <string>PSToggleSwitchSpecifier</string>
    <key>Title</key>
    <string>Night Mode</string>
    <key>Key</key>
    <string>isNightMode</string>
    <key>DefaultValue</key>
    <false/>
</dict>
struct Theme {
  var isNightMode:Bool {
    return UserDefaults.standard.bool(forKey: "isNightMode")
  }
  var backgroundColor:UIColor {
    return isNightMode ? .black : .white
  }
  var foregroundColor:UIColor{
    return isNightMode ? .white : .black
  }
}
ytyubox commented 5 years ago

開啟設定頁的方法 UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)