CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Jun 2017 |
| SwiftSwift Version | 3.0 |
| SPMSupports SPM | ✗ |
Maintained by PatrickChow.
适用于Swift的夜间模式解决方案
运行ForOneNight(ForOneNight.xcodeproj)项目,设置自己需要的类型,然后Build得到Framework。
如何让419正确的开始运作?
419只管理2种模式的切换,它不关心一开始是那种模式,所以,在项目的开始,我们需要手动的设置。 这主要考虑到一些项目可能已经开始有标识两种模式的字段,所以内部不会有这样的逻辑。 最好这样:
application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
ForOneNight.default.isNight = true or false
...
...
}
如何使用419?
419使用起来非常简单,支持所有UIView和它的子类、UIBarItem和它的子类以及CALayer,之后会支持其他需要支持的类。 通过 . 可以获取到nv,之后就可以通过提示查看它所支持的属性,或者直接到源码中查看。 比如设置一个view的背景:
view.nv?.backgroundColor(UIColor.white, night: UIColor.black)
在UILabel中设置属性字符attributedText可以使用:
textLabel.nv?.attributesText(mutableAttributedString)
而组装所需要的NSAttributedString时,为其中的key: NSForegroundColorAttributeName ,目前提供了这样的设置方式:
PropertyBox(day: UIColor.white, night: UIColor.black)
在有多个属性需要设置时,可以这样:
textLabel.nv?.backgroundColor(UIColor.white, night: UIColor.black).attributesText(mutableAttributedString)
需要注意的是,在CALayer中设置它的几个渲染属性,需要使用UIColor。
layer.nv?.set(borderColor: UIColor.white, night: UIColor.black)
如何切换模式?
在合适的时机调用switchVersion 即可
ForOneNight.default.switchVersion()
build 成功 ForOneNight 项目后,运行 Sample,如果遇到错误信息:
dyld: Library not loaded:
...
...
请在Sample->General->Embedded Binaries 中添加 ForOneNight.frameworks
欢迎提出你们的意见! email: [email protected]
qq: 254335290