Giter Club home page Giter Club logo

nightthememanager's Introduction

NightThemeManager

Language License

黑夜模式的简单实现,利用Objective-C分类进行对应属性绑定

导入

将项目中NightThemeManager 文件夹拖到项目里

或者使用Pod安装

pod 'SINightThemeManager', '~> 0.1.0'	

使用

  1. 导入头文件

    #import "NightThemeManager.h"
  2. 通过代码设置或者Xib设置不同主题的属性

    self.view.nightBackgroundColor = [UIColor blackColor];
    self.view.normalBackgroundColor = [UIColor whiteColor];

    通过xib设置如下图所示:

  3. 设计好相应的颜色后,调用下面方法改变主题

    [SINightThemeManager changeTheme] ;
  4. 改变某个UIView子类对象的主题

    首先需要实现下面这个非正式协议:

    @protocol SINightThemeProtocol <NSObject>
    
    - (void)themeChange ;
    - (void)themeChangeWithDuration:(NSTimeInterval)duration ;
    - (NSArray *)subviews ;
    
    @end

    调用下面这个方法进行改变:

    + (void)changeTheme:(UIView* )view ;
    + (void)changeTheme:(UIView* )view withDuartion:(NSTimeInterval)duration ;
  5. 发送的通知

    FOUNDATION_EXTERN NSString *const SINightThemeChangeNotification ;  // 将要改变主题
    FOUNDATION_EXTERN NSString *const SINightFallingNotification ;  // 将要变为黑夜主题
    FOUNDATION_EXTERN NSString *const SIDawnComingNotification ;  // 将要变为白天主题
  6. 通知携带着主题将要改变的主题和旧的主题信息,保存于userinfo字典中,字典对应的key如下

    FOUNDATION_EXTERN NSString *const SINightThemeOldThemeKey ;  // 旧主题对应Key
    FOUNDATION_EXTERN NSString *const SINightThemeNewThemeKey ;  // 新主题对应Key

要求

iOS 7 or later.

NightThemeManager

NightThemeManager is available under the MIT license. See the LICENSE file for more info.

nightthememanager's People

Contributors

silence0201 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

codelem

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.