{"id":20087986,"url":"https://github.com/lixiang1994/leetheme","last_synced_at":"2025-04-06T18:13:19.463Z","repository":{"id":55598063,"uuid":"56833564","full_name":"lixiang1994/LEETheme","owner":"lixiang1994","description":"优雅的主题管理库- 一行代码完成多样式切换","archived":false,"fork":false,"pushed_at":"2024-09-06T12:17:29.000Z","size":198123,"stargazers_count":825,"open_issues_count":6,"forks_count":134,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-30T17:08:06.781Z","etag":null,"topics":["cocoapods","color","demo","identifier","image","ios","json","lee","model","night","night-mode","nsobject","objective-c","style","theme"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lixiang1994.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-22T06:59:26.000Z","updated_at":"2025-02-13T03:07:34.000Z","dependencies_parsed_at":"2024-11-13T16:21:16.912Z","dependency_job_id":null,"html_url":"https://github.com/lixiang1994/LEETheme","commit_stats":{"total_commits":186,"total_committers":4,"mean_commits":46.5,"dds":0.5053763440860215,"last_synced_commit":"8da92fb06bcf81e81f530dd09dc9e813622cd005"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixiang1994%2FLEETheme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixiang1994%2FLEETheme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixiang1994%2FLEETheme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixiang1994%2FLEETheme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lixiang1994","download_url":"https://codeload.github.com/lixiang1994/LEETheme/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247526753,"owners_count":20953143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapods","color","demo","identifier","image","ios","json","lee","model","night","night-mode","nsobject","objective-c","style","theme"],"created_at":"2024-11-13T16:10:59.456Z","updated_at":"2025-04-06T18:13:19.441Z","avatar_url":"https://github.com/lixiang1994.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# LEETheme - 最好用的轻量级主题管理框架\n\n[![](https://img.shields.io/cocoapods/l/LEETheme.svg)](LICENSE)\u0026nbsp;\n[![](http://img.shields.io/cocoapods/v/LEETheme.svg?style=flat)](http://cocoapods.org/?q=LEETheme)\u0026nbsp;\n[![](http://img.shields.io/cocoapods/p/LEETheme.svg?style=flat)](http://cocoapods.org/?q=LEETheme)\u0026nbsp;\n[![](https://img.shields.io/badge/support-iOS7%2B-blue.svg?style=flat)](https://www.apple.com/nl/ios/)\u0026nbsp;\n[![](https://img.shields.io/badge/Xcode-11.0-blue.svg)](https://developer.apple.com/xcode/)\u0026nbsp;\n[![](https://img.shields.io/badge/language-Objective--C-f48041.svg?style=flat)](https://www.apple.com/)\u0026nbsp;\n![Build Status](https://travis-ci.org/lixiang1994/LEETheme.svg?branch=master)\u0026nbsp;\n![](https://img.shields.io/cocoapods/dt/LEETheme.svg)\n\n\n演示\n==============\n![新日间Demo演示](https://github.com/lixiang1994/Resources/blob/master/LEETheme/社区日间.gif)\n![新夜间Demo演示](https://github.com/lixiang1994/Resources/blob/master/LEETheme/社区夜间.gif)\n\n![新日间Demo演示](https://github.com/lixiang1994/Resources/blob/master/LEETheme/微博日间.gif)\n![新夜间Demo演示](https://github.com/lixiang1994/Resources/blob/master/LEETheme/微博夜间.gif)\n\n\n特性\n==============\n- 链式语法 结构优雅\n- 两种设置模式,可根据对象单独添加某一主题中某一属性或方法的设置,可使用标识符模式为某一属性或方法设置标识符,二者可混合使用,满足不同需求的开发者。\n- 轻量级设计, 简化文件架构, 全部集合为两个文件中。\n- 支持对所有NSObject子类对象进行设置, 并提供了常用视图对象的颜色和图片等属性的快捷设置方法。\n- 支持自定义类型对象的自定义属性或方法设置。\n- 支持动态添加主题,可实现类似网络主题下载并切换的功能。\n- 语法优雅, 高效简洁, OC链式, 一行代码完成对象设置。\n- 当前主题记忆功能, 下一次启动自动布置。\n- 完善的文档注释和使用教程, 并有众多Demo可供参考。\n\n\n用法\n==============\n\n### 默认模式\n\n主要适用于固定主题样式的情况下使用\n \n 优点:直观 清晰, 编码时可随初始化控件编写完成, 不影响编码思路.\n \n 缺点:每个主题的设置固定, 不支持新主题的设置.\n\n\n\t// 添加背景颜色\n\timageView.lee_theme\n    .LeeAddBackgroundColor(@\"red\" , [UIColor redColor])\n    .LeeAddBackgroundColor(@\"blue\" , [UIColor blueColor]);\n\t\n\t// 添加图片\n\timageView.lee_theme\n    .LeeAddImage(@\"red\" , [UIImage imageNamed:@\"red.png\"])\n    .LeeAddImage(@\"blue\" , [UIImage imageNamed:@\"blue.png\"]);\n\t\n\t// 添加自定义设置 (每个主题标签对应一个block , 当触发其中添加的主题后会执行相应的block)\n\timageView.lee_theme\n    .LeeAddCustomConfig(@\"red\" , ^(UIImageView *item){\n        \n        item.hidden = YES; //简单举例 红色主题启动时 将这个imageview对象隐藏\n    })\n    .LeeAddCustomConfig(@\"blue\" , ^(UIImageView *item){\n        \n        item.hidden = NO; //或者随便做一些其他羞羞的事\n    });\n\n\nLEETheme支持对任何NSObject子类的对象进行其持有属性或方法的设置 , 例如UIImageView类的对象持有image属性 , 那么使用LEETheme就可以为它设置不同主题对应的image属性值, 以此类推 , 当然所有类型的对象都可以添加自定义Block设置.\n\n### 标识符模式\n\t\n 适用于固定和动态主题样式的情况下使用\n \n 优点:对于对象的设置只需要给定标识符即可, 代码较默认模式更加简洁, 可动态增加新主题JSON配置.\n\n##### JSON标准格式\n\n\t{\n\t\t\"color\": {\n\t\t   \t\"identifier1(唯一标识符)\": \"十六进制颜色值\",\n\t\t    \t\"identifier2\": \"#000000\"\n\t\t},\n\t\t\"image\": {\n\t\t\t\"identifier3(唯一标识符)\": \"图片名称\",\n\t\t\t \"identifier4\": \"lee.png\"\n\t\t},\n\t\t\"other\": {\n\t\t\t\"identifier5(唯一标识符)\": \"其他值\",\n\t\t\t \"identifier6\": \"12345\"\n\t\t}\n\t}\n\n这里一般分为3种类型\n\n1. 颜色类型 (color) - 适用于颜色属性\n2. 图片类型 (image) - 适用于图片属性\n3. 其他类型 (other) - 适用于自定义Block\n\n![JSON配置关系图](https://github.com/lixiang1994/LEETheme/blob/master/Resources/JSON配置关系图.png)\n\n##### 添加新主题的JSON配置\n```\n/**\n * 添加json , 设置所属主题标签 , 设置资源路径  所添加过的Json配置会自动存储 无需每次都添加\n * 关于资源路径的设置 只需要传入documents目录后的路径即可 如:@\"theme_resources/black\"\n */\n [LEETheme addThemeConfigWithJson:json Tag:@\"red\" ResourcesPath:nil];\n```\n##### 移除某一主题的JSON配置\n\n\t// 所要移除的主题标签\n\t[LEETheme removeThemeConfigWithTag:@\"red\"];\n\n##### 对象设置\n\n\t// 设置背景颜色\n\timageView.lee_theme.LeeConfigBackgroundColor(@\"identifier2\");\n\t\n\t// 设置图片\n\timageView.lee_theme.LeeConfigImage(@\"identifier4\");\n\n\t// 自定义设置 (如果没有对应的标识符 则不会触发该block执行 , 如果有 则执行)\n\timageView.lee_theme.LeeCustomConfig(@\"identifier6\" , ^(id item , id value){\n\t\t\t\n\t\t//item 为当前对象\n\t\t//value 为当前主题的JSON配置中 other 类型下 \"identifier6\"对应的值\n\t\titem.alpha = [value floatValue]; //举个例子 设置一下透明度\n\t});\n\n\n### 启用主题\n\n启用主题后 , LEETheme会自动保存当前所启用的主题 , APP下一次开启会自动启用上一次的主题.\n\n\t// 启用主题\n\t[LEETheme startTheme:@\"主题标签\"];\n\t\n建议在`- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions`中添加默认主题的设置 , 指定第一次启动APP时默认启用的主题.\t\n\t\n\t// 设置默认主题\n\t[LEETheme defaultTheme:@\"主题标签\"];\n\t\n### 关于添加过渡动画效果\n\n这里提供一个小技巧 可以让过渡更加自然 可根据自身情况调整使用.\n切换主题前 获取当前window的快照视图 并覆盖到window上 \u003e 执行主题切换 \u003e 将覆盖的快照视图通过动画隐藏 显示出切换完成的真实window.\n\n\n\t// 覆盖截图\n\tUIView *tempView = [weakSelf.window snapshotViewAfterScreenUpdates:NO];\n\t[weakSelf.window addSubview:tempView];\n\t\n\t// 切换主题\n\t[LEETheme startTheme:@\"tag\"];\n\t\n\t// 增加动画 移除覆盖\n\t[UIView animateWithDuration:1.0f animations:^{\n                \n\t\ttempView.alpha = 0.0f;\n                \n\t} completion:^(BOOL finished) {\n                \n\t\t[tempView removeFromSuperview];\n\t}];\n\n\n### 注意事项\n\n- 默认模式与标识符模式可以同时使用.\n- 当一个对象同时使用了2种设置模式 那么同主题情况下会优先使用后设置的.\n- JSON中的标识符(identifier)要确保在当前JSON中是唯一的.\n- 每个主题对应的JSON中 标识符(identifier)要相同.\n- 不要忘记设置默认主题, 应用中应该最少会有一个默认的主题.\n\n更多示例Demo\n==============\n\n[新闻资讯详情Demo](https://github.com/lixiang1994/NewsDetailsDemo)\n\n安装\n==============\n\n### CocoaPods\n\n1. 将 cocoapods 更新至最新版本.\n2. 在 Podfile 中添加 `pod 'LEETheme'`。\n3. 执行 `pod install` 或 `pod update`。\n4. 导入 `\u003cLEETheme/LEETheme.h\u003e`。\n\n### 手动安装\n\n1. 下载 LEETheme 文件夹内的所有内容。\n2. 将 LEETheme 内的源文件添加(拖放)到你的工程。\n3. 导入 `LEETheme.h`。\n\n系统要求\n==============\n该库最低支持 `iOS 7.0` 和 `Xcode 9.0`。\n\n\n版本更新\n==============\n详情请查看[更新日志](https://github.com/lixiang1994/LEETheme/blob/master/UPDATELOG.md)\n\n\n许可证\n==============\nLEETheme 使用 MIT 许可证，详情见 [LICENSE](LICENSE) 文件。\n\n\n友情链接\n==============\n[高效的自动布局库 - SDAutoLayout](https://github.com/gsdios/SDAutoLayout)\n\n\n个人主页\n==============\n[我的简书](http://www.jianshu.com/users/a6da0db100c8)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flixiang1994%2Fleetheme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flixiang1994%2Fleetheme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flixiang1994%2Fleetheme/lists"}