SwiftTheme
先看效果

因为项目是oc写的, 而SwiftTheme底层是swift,所以项目上还要做一些设置
0. 配置工程.设置Defines Module 为Yes

1.设置Product Module Name 为当前工程名

2.配置Podfile文件

3.安装SwiftTheme
0.打开终端.cd 你项目的路径
1.pod install
4.创建oc调用swift的桥接文件
文件名为你项目的名字-Bridging-Header

选择Create Bridging Header

也可以自己创建桥接文件

文件名同样为你项目的名字-Bridging-Header,在文件包含SwiftTheme

修改桥接文件路径

5.在项目中使用SwiftTheme
打开SwiftTheme找到这三个文件,拖到你得工程里

6.你项目的pch文件里引入这三个文件

7.接下来你就可以像oc一样调用这个框架
怎么使用这个框架
tabBar
UITabBar *tabBar = [UITabBar appearance];
tabBar.theme_tintColor = globalBarTextColorPicker;
nav
/// 全局去掉黑线
UINavigationBar *navigationBar = [UINavigationBar appearance];
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowOffset = CGSizeZero;
NSMutableArray *titleAttributes = [NSMutableArray array];
for (NSString *rgba in globalNavColors) {
UIColor *color = [[UIColor alloc] initWithRgba_throws:rgba error:nil];
NSDictionary *attr = @{
NSForegroundColorAttributeName: color,
NSFontAttributeName: [UIFont systemFontOfSize:20],
NSShadowAttributeName: shadow
};
[titleAttributes addObject:attr];
}
navigationBar.theme_tintColor = globalBarTextColorPicker;
navigationBar.theme_barTintColor = globalBarTintColorPicker;
navigationBar.theme_titleTextAttributes = [ThemeDictionaryPicker pickerWithDicts:titleAttributes];
调用
/// 在你需要换肤的地方,调用这个方法
[MyThemes switchToNext];
Global文件

在这里你可以配置你需要颜色
你可能需要颜色进制转换在线工具
最后贴上效果图

网友评论