lizelu / cethemeswitcher Goto Github PK
View Code? Open in Web Editor NEWhttp://www.cnblogs.com/ludashi/p/6289741.html
http://www.cnblogs.com/ludashi/p/6289741.html
感谢提供这么通俗易懂的教程
class ThemeManager: NSObject {
/// 当前使用的主题
var theme: ThemeProtocol = NormalTheme() //默认是NormalTheme
var type: ThemeType = .normal
/// .....
//MARK: - Private Method
/// ThemeManager的私有构造器
private override init() {}
/// 切换主题的方法
///
/// - Parameter type: 要切换主题的枚举类型
private func switcherTheme(type: ThemeType){
self.theme = type.theme
self.type = type
NotificationCenter.default.post(name: ThemeNotifacationName, object: self.theme)
}
}
这样在其它地方可以获取到当前主题是哪一套,比如设置 self.navigationController?.navigationBar.barStyle
的时候,就可以通过这个来判断了
if ThemeManager.shareInstance().type == .normal {
self.navigationController?.navigationBar.barStyle = .default
} else {
self.navigationController?.navigationBar.barStyle = .black
}
大大还有更优雅的实现方法吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.