SwiftTheme
先看效果
效果图.gif
因为项目是oc写的, 而SwiftTheme底层是swift,所以项目上还要做一些设置
0. 配置工程.设置Defines Module 为Yes
配置工程.设置Defines Module 为Yespng
1.设置Product Module Name 为当前工程名
设置Product Module Name 为当前工程名 .png
2.配置Podfile文件
配置Podfile文件.png
3.安装SwiftTheme
0.打开终端.cd 你项目的路径
1.pod install
4.创建oc调用swift的桥接文件
文件名为你项目的名字-Bridging-Header
0.png
选择Create Bridging Header
1png
也可以自己创建桥接文件
3png
文件名同样为你项目的名字-Bridging-Header,在文件包含SwiftTheme
E58495EB-9ADE-45D8-ABAF-21342AB6AB11.png
修改桥接文件路径
50B21C1C-A091-4D22-9673-14AA97AFBDE2.png
5.在项目中使用SwiftTheme
打开SwiftTheme找到这三个文件,拖到你得工程里
E6F71CAF-3221-47AE-85AC-A13CE275304B.png
6.你项目的pch文件里引入这三个文件
B4A40001-2179-4376-AF88-ADB24DAB5DD2.png
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文件
80A7B75F-05CC-4A79-876E-CF67DF1035ED.png
在这里你可以配置你需要颜色
你可能需要颜色进制转换在线工具
最后贴上效果图
Untitled.gif










网友评论