[Swift 开发] iOS换肤框架 SwiftTheme
发布时间:2020-12-14 06:52:00 所属栏目:百科 来源:网络整理
导读:SwiftTheme是目前iOS平台上最方便的换肤框架,而且功能丰富、高性能、可扩展,提供一个全新的换肤解决方案,使用纯Swift编写,但完全兼容OC。 框架网上可以搜到,咱们今天主要讲一下用法. 1.先定义一些主题颜色 let globalBackgroundColorPicker = ThemeColor
SwiftTheme是目前iOS平台上最方便的换肤框架,而且功能丰富、高性能、可扩展,提供一个全新的换肤解决方案,使用纯Swift编写,但完全兼容OC。
框架网上可以搜到,咱们今天主要讲一下用法. 1.先定义一些主题颜色 let globalBackgroundColorPicker = ThemeColorPicker(colors: "#EB4F38","#F4C600","#56ABE4","#ECF0F1") //在MyThemes中设置主题 case Red = 0 case Yello = 1 case Blue = 2 case Night = 3 2.把需要换肤的控件都加进来 //UIButton btn.theme_backgroundColor = globalBackgroundColorPicker btn.theme_setTitleColor(ThemeColorPicker(colors: "#000","#FFF"),forState: .Normal) <pre name="code" class="objc">//UILabellabel.theme_textColor = globalBackgroundColorPicker //UINavigationBar navigationBar.theme_tintColor = globalBarTintColorPicker navigationBar.theme_barTintColor = globalBarTintColorPicker //UIImage nightIcon.theme_image = ThemeImagePicker(names: "icon_night_dark","icon_night_dark","icon_night_light") 3.换肤 //循环换肤 MyThemes.switchToNext() //切换到哪个主题 MyThemes.switchTo(MyThemes.Blue) //夜晚模式 MyThemes.switchToNight(true) plist 方式以下为用法示例:view.theme_backgroundColor = ThemeColorPicker(keyPath: "Global.backgroundColor") imageView.theme_image = ThemeImagePicker(keyPath: "SelectedThemeCell.iconImage") 上面用到的 plist 、
image 展示如下: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |