Giter VIP home page Giter VIP logo

cethemeswitcher's People

Contributors

lizelu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cethemeswitcher's Issues

建议在ThemeManager里再加一个 type 用来区分当前主题是哪一套

感谢提供这么通俗易懂的教程

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
}

大大还有更优雅的实现方法吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.