Latest 1.0.8
Homepage https://github.com/Maoyis/QXTheme
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

Example

DEMO

short1
short2
short3

Requirements

  • iOS 8.0+

主题文件目前只支持plist以及json文件

Installation

QXTheme is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'QXTheme'

Use

  1. 初始配置一个默认主题(推荐在AppDelegate.h的 – (BOOL)application:application didFinishLaunchingWithOptions:方法中设置)

    dispatch_async(dispatch_get_main_queue(), ^{
    [QXThemeManager initDefaultThemeWithFileName:@"Theme_Day.plist"];
    [QXThemeManager refreshTheme];
    });

  2. 控件定制主题方法:

    普通使用:

    [self.label qx_OrderPacks:^(QXThemeStaff *staff) {
        staff.packing(@selector(setTextColor:), @[COLOR_ATTR(@"textColor1")]);
        staff.packing(@selector(setFont:), @[FONT_ATTR(@"labelFont")]);
        staff.packing(@selector(setBackgroundColor:), @[COLOR_ATTR(@"themeColor")]);
        staff.packing(@selector(setText:), @[TEXT_ATTR(@"labelText")]);
    }];
    [self.label.layer qx_OrderPacks:^(QXThemeStaff *staff) {
        staff.packing(@selector(setCornerRadius:), @[@6]);//偷下懒。这些也可以定制
        staff.packing(@selector(setBorderWidth:), @[@1]);
        staff.packing(@selector(setBorderColor:), @[COLOR_ATTR(@"textColor1")]);
    }];

    链式用法:

    [self.navigationBar qx_OrderPacks:^(QXThemeStaff *staff) {
    staff.
    packing(@selector(setTranslucent:), @[OTHER_ATTR(@"nav_translucent")]).
    packing(@selector(setBarTintColor:), @[COLOR_ATTR(@"themeColor")]).
    packing(@selector(setTintColor:), @[COLOR_ATTR(@"tabbar_selectColor")]);
    
    staff.packing(@selector(setTitleTextAttributes:),
                  @[@{NSFontAttributeName:FONT_ATTR(@"navTitle"),
                      NSForegroundColorAttributeName:COLOR_ATTR(@"tabbar_selectColor")}]);

    }];

    PS:定制属性需要通过COLOR_ATTR、FONT_ATTR、TEXT_ATTR、IMAGE_ATTR、OTHER_ATTR包装对应的主题颜色、字体、文本、图片,以及其他一些属性(如:是否透明,圆角,frame等)

  3. 修改主题:

    //修改当前主题
    [QXThemeManager changeThemeWithTag:@"themeColor" value:hexStr tagType:QXThemeTagTypeOfColor];
  4. 切换主题

    [QXThemeManager changeThemeWithFileName:@"新主题.json"];
  5. 导出主题

        if (![[QXThemeManager shareManager].curTheme exportThemeFileWithFileType:QXThemeFileTypeJson name:@"ThemeName" path:@"myDesktop/QXTheme" error:&error]) {
        NSLog(@"导出失败Error:%@", error.localizedDescription);
        }

    Log

  • 1.0.7:
    新增compareCurThemeWithName:接口用于比较当前主题

Author

Maoyis, [email protected]

License

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

Latest podspec

{
    "name": "QXTheme",
    "version": "1.0.8",
    "summary": "Excellent theme management library.",
    "description": "TODO: Using the chain structure, it provides a simple way to switch the theme and make the custom control not so complicated.",
    "homepage": "https://github.com/Maoyis/QXTheme",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Maoyis": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Maoyis/QXTheme.git",
        "tag": "1.0.8"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "QXTheme/Classes/**/*"
}

Pin It on Pinterest

Share This