{"id":15036174,"url":"https://github.com/chenyilong/cyltabbarcontroller","last_synced_at":"2025-05-13T23:07:02.781Z","repository":{"id":39254208,"uuid":"44896762","full_name":"ChenYilong/CYLTabBarController","owner":"ChenYilong","description":"[EN]It is an iOS UI module library for adding animation to iOS tabbar items and icons with Lottie, and adding a bigger center UITabBar Item.  [CN]【中国特色 TabBar】一行代码实现 Lottie 动画TabBar，支持中间带+号的TabBar样式，自带红点角标，支持动态刷新。【iOS13 \u0026 Dark Mode  \u0026 iPhone XS MAX supported】","archived":false,"fork":false,"pushed_at":"2023-12-15T02:43:36.000Z","size":57491,"stargazers_count":6953,"open_issues_count":164,"forks_count":1458,"subscribers_count":161,"default_branch":"master","last_synced_at":"2025-05-10T22:01:55.703Z","etag":null,"topics":["animation","animation-library","cocoapods","darkmode","ios","ios13","lottie","lottie-ios","objc","objective-c","storyboard","swift","tabbar","tabbarcontroller","ui","uikit","view","xcode","xib"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/ChenYilong.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2015-10-25T04:43:55.000Z","updated_at":"2025-05-09T09:32:56.000Z","dependencies_parsed_at":"2022-08-09T13:53:15.484Z","dependency_job_id":"f81bb5a0-dddb-490b-ac84-cc9e1c8e47f9","html_url":"https://github.com/ChenYilong/CYLTabBarController","commit_stats":{"total_commits":373,"total_committers":16,"mean_commits":23.3125,"dds":0.09919571045576403,"last_synced_commit":"7f72f53266cb934ddf428b5d5203d9da51d2da6e"},"previous_names":[],"tags_count":122,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChenYilong%2FCYLTabBarController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChenYilong%2FCYLTabBarController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChenYilong%2FCYLTabBarController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChenYilong%2FCYLTabBarController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChenYilong","download_url":"https://codeload.github.com/ChenYilong/CYLTabBarController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254041060,"owners_count":22004655,"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":["animation","animation-library","cocoapods","darkmode","ios","ios13","lottie","lottie-ios","objc","objective-c","storyboard","swift","tabbar","tabbarcontroller","ui","uikit","view","xcode","xib"],"created_at":"2024-09-24T20:30:25.376Z","updated_at":"2025-05-13T23:06:57.768Z","avatar_url":"https://github.com/ChenYilong.png","language":"Swift","readme":"\u003cp align=\"center\"\u003e\u003ca href=\"https://github.com/ChenYilong/CYLTabBarController\"\u003e\u003cimg src=\"https://repository-images.githubusercontent.com/44896762/c1d6e880-a8d8-11e9-8bb4-2da8ebc06f0a\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n# [CN]CYLTabBarController【一行代码实现 Lottie 动画 TabBar】\n# [EN]CYLTabBarController [An animated tabBar supported by Lottie with one line of code] \n\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/ChenYilong/CYLTabBarController/blob/master/CYLTabBarController.podspec\"\u003e\u003cimg src=\"https://img.shields.io/badge/Pod-GetLatestVersion-green.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"\"\u003e\u003cimg src=\"https://img.shields.io/badge/Swift-compatible-orange.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"\"\u003e\u003cimg src=\"https://img.shields.io/badge/platform-iOS%208.0%2B-ff69b5152950834.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/ChenYilong/CYLTabBarController/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-green.svg?style=flat\"\u003e\u003c/a\u003e\n\n\u003c/p\u003e\n\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/ChenYilong/iOSBlog/issues/21\"\u003e\u003cimg src=\"https://img.shields.io/static/v1.svg?label=QQ%E3%80%81Telegram%20Group\u0026color=blue\u0026message=%E7%82%B9%E5%87%BB%E8%8E%B7%E5%8F%96QQ%E3%80%81Telegram%E7%BE%A4%E4%BF%A1%E6%81%AF\u0026color=green\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/ChenYilong/CYLTabBarController/releases.atom\"\u003e\u003cimg src=\"https://img.shields.io/badge/RSS feed (full text feed)-订阅仓库版本更新-yellow.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/ChenYilong/iOSBlog/releases.atom\"\u003e\u003cimg src=\"https://img.shields.io/badge/RSS feed (full text feed)-订阅我的博客更新-yellow.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"http://ww4.sinaimg.cn/large/006tNc79ly1g5zsnmaw40g30go04ck08.gif\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n \u003ca href=\"http://ww2.sinaimg.cn/large/006tNc79ly1g5et6q6sm5j30go0goaar.jpg\"\u003e\u003cimg src=\"http://ww1.sinaimg.cn/large/006tNc79ly1g5esb5j4oaj300w00rdfn.jpg\"\u003e\u003c/a\u003e\n\u003ca href=\"http://weibo.com/luohanchenyilong\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6ly1g6um2edt3jj300w00q3y9.jpg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://twitter.com/iOSChenYilong\"\u003e\u003cimg src=\"http://ww3.sinaimg.cn/large/006tNc79ly1g5erhikv2kj300w00wgld.jpg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/ChenYilong\"\u003e\u003cimg src=\"http://ww3.sinaimg.cn/large/006tNc79gy1g5ercvzgxzj300w00wmwx.jpg\"\u003e\u003c/a\u003e \n\u003ca href=\"https://qm.qq.com/cgi-bin/qm/qr?k=SEdIYBh52YzquCEo8cmPwgkko1VgSAlw\u0026authKey=sGcG%2BGB81DW%2Ba8v3dCufFSNoxhykAU61Uz%2B%2BqDiKQN2BGHP2xHYVI2tc0Cah2lpu\"\u003e\u003cimg src=\"http://ww1.sinaimg.cn/large/006tNc79ly1g5euf38fedj300w00wjr5.jpg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://t.me/iosobjc\"\u003e\u003cimg src=\"http://ww2.sinaimg.cn/large/006tNc79ly1g5eus39934j300w00w0r1.jpg\"\u003e\u003c/a\u003e\n\u003ca href=\"http://s.zhihu.com/BU5Mp\"\u003e\u003cimg src=\"http://ww4.sinaimg.cn/large/006tNc79ly1g5eu9melwaj300w00w3ya.jpg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\n--------------------------------------------\n\n## [CN]阅读须知 \n## [EN]Before Reading \n\n - [CN] mark means Chinese language by default.\n - [EN] mark means English language.\n - [CN] [点此获取 QQ 群,Telegram 群交流信息]( https://github.com/ChenYilong/iOSBlog/issues/21) 。\n - [EN]Telegram Group to communicate the features or bugs: https://t.me/CYLTabBarController \n\n\n# [CN]谁在用?上架APP列表[EN]who are using?List  of App published \n\n\n\n\nAPP name link icon | image  |APP name link icon | image  \n:-------------:|:-------------:|:-------------:|:-------------:\n海底捞  [App Store Link](https://itunes.apple.com/cn/app/%E6%B5%B7%E5%BA%95%E6%8D%9E/id553115181?l=en\u0026mt=8)  ![enter image description here](https://is1-ssl.mzstatic.com/image/thumb/Purple123/v4/3f/8c/b2/3f8cb27c-8a47-82b2-fa08-25ca075cee59/AppIcon-1x_U007emarketing-85-220-0-9.png/690x0w.jpg) |  ![enter image description here](https://is5-ssl.mzstatic.com/image/thumb/Purple128/v4/20/78/c4/2078c481-aa68-c263-ee3b-22b797ec2209/pr_source.jpg/690x0w.jpg) | C家 [App Store Link](https://itunes.apple.com/cn/app/c%E5%AE%B6/id1123394197?l=en\u0026mt=8) ![enter image description here](https://is5-ssl.mzstatic.com/image/thumb/Purple113/v4/cf/9c/35/cf9c35c2-68fa-8d3a-e612-e2560501899b/AppIcon-0-1x_U007emarketing-0-0-85-220-0-5.png/690x0w.jpg) | Lottie 效果  ![](http://ww3.sinaimg.cn/large/006tNc79ly1g3aavtlekdg30ai0l2b2b.gif) | \n淘必中-淘宝推出的一款具有营销购物功能的APP [App Store Link](https://itunes.apple.com/cn/app/%E6%B7%98%E5%BF%85%E4%B8%AD/id399737960?l=en\u0026mt=8) ![enter image description here](https://is2-ssl.mzstatic.com/image/thumb/Purple125/v4/f2/8d/58/f28d5806-bf9d-b77b-4e41-5986d96d250b/AppIcon-1x_U007emarketing-85-220-4.png/690x0w.jpg ) | ![enter image description here](https://is4-ssl.mzstatic.com/image/thumb/Purple125/v4/67/04/be/6704be9c-de16-fcdd-0376-7bf66a3e3f82/pr_source.png/690x0w.png) | 慧诊健康  [App Store Link](https://itunes.apple.com/cn/app/%E6%85%A7%E8%AF%8A%E5%81%A5%E5%BA%B7/id1434271846?mt=8) ![enter image description here](https://is3-ssl.mzstatic.com/image/thumb/Purple124/v4/b4/ae/d3/b4aed30e-996e-2fcc-0234-ebff091c861d/AppIcon-0-1x_U007emarketing-0-0-85-220-0-10.png/690x0w.jpg)|![enter image description here](https://is3-ssl.mzstatic.com/image/thumb/Purple118/v4/6d/f3/33/6df33378-da60-45b3-1c2a-9d286f12ce55/mzl.vgjiebgy.png/690x0w.jpg)\n究竟大学 [App Store Link](https://itunes.apple.com/us/app/%E7%A9%B6%E7%AB%9F%E5%A4%A7%E5%AD%A6/id1334531245?mt=8)  ![enter image description here](https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/d8/4a/95/d84a9596-3d02-881e-7646-e90954ffa8bc/AppIcon-0-1x_U007emarketing-0-0-85-220-6.png/690x0w.jpg) | ![enter image description here](https://is1-ssl.mzstatic.com/image/thumb/Purple123/v4/ca/4f/f4/ca4ff420-ec42-cc9d-7c8f-d7df388a184d/pr_source.png/690x0w.jpg) | 蕉片 - 短视频拍摄剪辑出电影大片   [App Store Link](https://itunes.apple.com/us/app/%E8%95%89%E7%89%87-%E7%9F%AD%E8%A7%86%E9%A2%91%E6%8B%8D%E6%91%84%E5%89%AA%E8%BE%91%E5%87%BA%E7%94%B5%E5%BD%B1%E5%A4%A7%E7%89%87/id1235972800?mt=8)  ![enter image description here](https://is1-ssl.mzstatic.com/image/thumb/Purple128/v4/2c/14/68/2c1468de-5807-253d-baa4-54cd4b43d7a3/AppIcon-1x_U007emarketing-85-220-4.png/230x0w.jpg)|![](http://ww1.sinaimg.cn/large/006tNc79ly1g3aaq6rnekj30j615hq5m.jpg)\n闪剧 - 可以玩的短视频 [App Store Link](https://itunes.apple.com/us/app/%E9%97%AA%E5%89%A7-%E5%8F%AF%E4%BB%A5%E7%8E%A9%E7%9A%84%E7%9F%AD%E8%A7%86%E9%A2%91/id1360997439?mt=8) ![enter image description here](https://is2-ssl.mzstatic.com/image/thumb/Purple113/v4/e6/26/e0/e626e01e-b00d-c36c-fa3c-98c59e5b95b1/AppIcon-0-1x_U007emarketing-0-0-GLES2_U002c0-512MB-sRGB-0-0-0-85-220-0-0-0-7.png/690x0w.jpg)| ![enter image description here](https://is3-ssl.mzstatic.com/image/thumb/Purple113/v4/23/70/57/23705710-9ee4-f7f0-9763-1ad2e5cb7cf6/pr_source.jpg/690x0w.jpg) | 土狗云商城 [App Store Link](https://itunes.apple.com/cn/app/%E5%9C%9F%E7%8B%97%E4%BC%98%E4%BA%AB/id1239005385?mt=8)  ![enter image description here](https://is4-ssl.mzstatic.com/image/thumb/Purple113/v4/1c/06/93/1c0693ef-db45-de8c-5b39-1b966d58c930/AppIcon-0-1x_U007emarketing-0-0-85-220-0-7.png/690x0w.jpg)|![](http://ww4.sinaimg.cn/large/006tNc79ly1g3aaqwf078j30u01sxx6r.jpg)\nAnalyst.ai [App Store Link](https://itunes.apple.com/us/app/analyst-ai/id1345754742?mt=8) ![enter image description here](https://is1-ssl.mzstatic.com/image/thumb/Purple113/v4/33/89/1d/33891d65-022e-88a3-b495-7fea6fe77a32/AppIcon-0-1x_U007emarketing-0-0-85-220-0-5.png/690x0w.jpg)| ![enter image description here](https://is4-ssl.mzstatic.com/image/thumb/Purple123/v4/35/33/77/35337725-e80d-7b4c-6422-0cac61039917/pr_source.png/690x0w.jpg) | 美膳校园  [App Store Link](https://itunes.apple.com/us/app/%E7%BE%8E%E8%86%B3%E6%A0%A1%E5%9B%AD/id1447211131?mt=8)  ![enter image description here](https://is2-ssl.mzstatic.com/image/thumb/Purple113/v4/de/f7/be/def7be95-abc6-df2e-78c5-8318eae418be/AppIcon-0-1x_U007emarketing-0-0-85-220-0-2.png/690x0w.jpg)| ![enter image description here](https://is5-ssl.mzstatic.com/image/thumb/Purple128/v4/e0/e8/aa/e0e8aadf-6692-d974-7962-778160e7eb5f/pr_source.png/690x0w.png) \n 全聚星 [App Store Link](https://itunes.apple.com/us/app/%E5%85%A8%E8%81%9A%E6%98%9F/id1140827531?mt=8) ![enter image description here](https://is1-ssl.mzstatic.com/image/thumb/Purple128/v4/4d/a2/57/4da25727-eda7-c7f8-8ce5-3b44591f3863/AppIcon-1x_U007emarketing-85-220-4.png/690x0w.jpg) |![enter image description here](https://is4-ssl.mzstatic.com/image/thumb/Purple118/v4/be/5f/0c/be5f0cbb-0265-b34d-bc34-ab9859f97350/mzl.bwmxymgk.jpg/690x0w.jpg) | Yesoul  [App Store Link](https://itunes.apple.com/us/app/yesoul/id1144444969?mt=8) ![enter image description here](https://is5-ssl.mzstatic.com/image/thumb/Purple113/v4/3f/0b/80/3f0b80df-e7fd-7c86-c3d2-472393304509/AppIcon-0-1x_U007emarketing-0-0-sRGB-85-220-0-7.png/690x0w.jpg) | ![enter image description here](https://is4-ssl.mzstatic.com/image/thumb/Purple123/v4/bb/96/9f/bb969f5e-48e8-b721-2db3-cf26d7b916f8/pr_source.png/460x0w.jpg) \n贵州充电通 [App Store Link](https://itunes.apple.com/us/app/%E8%B4%B5%E5%B7%9E%E5%85%85%E7%94%B5%E9%80%9A/id1455932848?mt=8\u0026app=itunes\u0026ign-mpt=uo%3D4) ![enter image description here](https://is3-ssl.mzstatic.com/image/thumb/Purple113/v4/d5/db/44/d5db4437-d409-ff48-3c19-1feabbd7b2a1/AppIcon-0-1x_U007emarketing-0-0-sRGB-85-220-0-7.png/690x0w.jpg) | ![enter image description here](https://is4-ssl.mzstatic.com/image/thumb/Purple123/v4/17/51/23/17512338-5bf2-3f4a-bda8-c4986dfe5be6/pr_source.png/690x0w.jpg) | 卓尔购  [App Store Link](https://itunes.apple.com/cn/app/%E5%8D%93%E5%B0%94%E8%B4%AD-%E6%89%B9%E5%8F%91%E9%87%87%E8%B4%AD%E8%BF%9B%E8%B4%A7%E9%A6%96%E9%80%89/id1063104387?mt=8)  ![enter image description here](https://is3-ssl.mzstatic.com/image/thumb/Purple114/v4/3c/36/e5/3c36e51e-47e9-0526-5652-bbc6acf3739c/mzl.emuqqmck.png/690x0w.jpg) | ![enter image description here](https://is3-ssl.mzstatic.com/image/thumb/Purple125/v4/fc/eb/e2/fcebe232-3a72-93fc-ed3a-2942ac22ab79/pr_source.png/690x0w.png) \n卓越管家 [App Store Link](https://itunes.apple.com/cn/app//id1268483803?mt=8) ![enter image description here](https://is4-ssl.mzstatic.com/image/thumb/Purple123/v4/b9/6a/d8/b96ad81a-3805-b1c8-3a56-83940fed4b01/AppIcon-0-1x_U007emarketing-0-85-220-5.png/690x0w.jpg) | ![enter image description here](https://is3-ssl.mzstatic.com/image/thumb/Purple113/v4/ca/f8/f8/caf8f846-ddc9-2ada-99c3-9758fc099288/pr_source.png/690x0w.jpg) | 悦守护 [App Store Link](https://itunes.apple.com/cn/app/%E6%82%A6%E5%AE%88%E6%8A%A4/id1347678565?mt=8) | ![](http://ww2.sinaimg.cn/large/006tNc79ly1g3a9upgmmjj30j615iads.jpg)\n筑集采采购端 [App Store Link](https://itunes.apple.com/cn/app//id1041802973?mt=8)  ![enter image description here](https://is2-ssl.mzstatic.com/image/thumb/Purple123/v4/f4/d2/1d/f4d21df2-57da-e0a0-5de2-2c9437553fcb/AppIcon-0-1x_U007emarketing-0-0-85-220-7.png/690x0w.jpg) | ![](http://ww1.sinaimg.cn/large/006tNc79ly1g3aa9fncl1j30j60y3adb.jpg) |  筑集采供应端  [App Store Link](https://itunes.apple.com/fr/app//id1035221629?mt=8) ![enter image description here](https://is1-ssl.mzstatic.com/image/thumb/Purple113/v4/8f/ba/6e/8fba6ec9-97e2-e008-f2f2-a30a1641cfa6/AppIcon-0-1x_U007emarketing-0-0-85-220-7.png/690x0w.jpg) |  ![](http://ww3.sinaimg.cn/large/006tNc79ly1g3aaa6itrcj30j60y30xl.jpg) | \n桂富宝  [App Store Link](https://itunes.apple.com/nz/app/e%E8%81%94%E7%9B%9F%E5%95%86%E5%9F%8E/id979819957)  ![enter image description here](https://is2-ssl.mzstatic.com/image/thumb/Purple113/v4/6f/62/22/6f6222c7-e54e-2ea7-feb7-ce481e562248/AppIcon-0-1x_U007emarketing-0-0-85-220-0-10.png/690x0w.jpg) | ![enter image description here](https://is5-ssl.mzstatic.com/image/thumb/Purple123/v4/4c/80/90/4c8090af-17b4-c152-2ba3-3037d5e7e905/pr_source.png/690x0w.jpg) |  小猪奔奔  [App Store Link](https://itunes.apple.com/cn/app/%E5%B0%8F%E7%8C%AA%E5%A5%94%E5%A5%94-%E7%94%A8%E6%88%B7%E7%89%88/id1124274649?mt=8) ![enter image description here](https://is5-ssl.mzstatic.com/image/thumb/Purple62/v4/78/b6/fd/78b6fde6-084b-3503-b2eb-3e85fa30beb0/AppIcon-1x_U007emarketing-85-220-4.png/690x0w.jpg) | ![enter image description here](https://is4-ssl.mzstatic.com/image/thumb/Purple118/v4/c8/d5/5e/c8d55e4d-9a39-0f12-d121-1bb15d8fed56/mzl.iizreksh.png/690x0w.jpg)\n娃娃坞(开发中)![](http://ww3.sinaimg.cn/large/006tNc79ly1g3aaruxhn1j30j60j60t3.jpg) |  ![](http://ww1.sinaimg.cn/large/006tNc79ly1g3aaf0s1yhj30l005iwer.jpg) | 更多APP请访问 [《使用 CYLTabBarController 做的 APP，来这里报道下吧》]( https://github.com/ChenYilong/CYLTabBarController/issues/314 )  | 如果你正在使用也请提交到这里 [《使用 CYLTabBarController 做的 APP，来这里报道下吧》]( https://github.com/ChenYilong/CYLTabBarController/issues/314 ) \n\n\n\n## [CN]导航 \n## [EN]CONTENTS \n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n\n- [与其他自定义TabBarController的区别](#%E4%B8%8E%E5%85%B6%E4%BB%96%E8%87%AA%E5%AE%9A%E4%B9%89tabbarcontroller%E7%9A%84%E5%8C%BA%E5%88%AB)\n- [集成后的效果：](#%E9%9B%86%E6%88%90%E5%90%8E%E7%9A%84%E6%95%88%E6%9E%9C)\n- [项目结构](#%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84)\n- [使用CYLTabBarController](#%E4%BD%BF%E7%94%A8cyltabbarcontroller)\n  - [第一步：使用CocoaPods导入CYLTabBarController](#%E7%AC%AC%E4%B8%80%E6%AD%A5%E4%BD%BF%E7%94%A8cocoapods%E5%AF%BC%E5%85%A5cyltabbarcontroller)\n  - [第二步：设置CYLTabBarController的两个数组：控制器数组和TabBar属性数组](#%E7%AC%AC%E4%BA%8C%E6%AD%A5%E8%AE%BE%E7%BD%AEcyltabbarcontroller%E7%9A%84%E4%B8%A4%E4%B8%AA%E6%95%B0%E7%BB%84%E6%8E%A7%E5%88%B6%E5%99%A8%E6%95%B0%E7%BB%84%E5%92%8Ctabbar%E5%B1%9E%E6%80%A7%E6%95%B0%E7%BB%84)\n  - [第三步：将CYLTabBarController设置为window的RootViewController](#%E7%AC%AC%E4%B8%89%E6%AD%A5%E5%B0%86cyltabbarcontroller%E8%AE%BE%E7%BD%AE%E4%B8%BAwindow%E7%9A%84rootviewcontroller)\n  - [第四步（可选）：创建自定义的形状不规则加号按钮](#%E7%AC%AC%E5%9B%9B%E6%AD%A5%E5%8F%AF%E9%80%89%E5%88%9B%E5%BB%BA%E8%87%AA%E5%AE%9A%E4%B9%89%E7%9A%84%E5%BD%A2%E7%8A%B6%E4%B8%8D%E8%A7%84%E5%88%99%E5%8A%A0%E5%8F%B7%E6%8C%89%E9%92%AE)\n- [补充说明](#%E8%A1%A5%E5%85%85%E8%AF%B4%E6%98%8E)\n  - [自定义 `TabBar` 样式](#%E8%87%AA%E5%AE%9A%E4%B9%89-tabbar-%E6%A0%B7%E5%BC%8F)\n    - [捕获 TabBar 点击事件](#%E6%8D%95%E8%8E%B7-tabbar-%E7%82%B9%E5%87%BB%E4%BA%8B%E4%BB%B6)\n  - [点击 TabBarButton 时添加动画](#%E7%82%B9%E5%87%BB-tabbarbutton-%E6%97%B6%E6%B7%BB%E5%8A%A0%E5%8A%A8%E7%94%BB)\n  - [横竖屏适配](#%E6%A8%AA%E7%AB%96%E5%B1%8F%E9%80%82%E9%85%8D)\n  - [访问初始化好的 CYLTabBarController 对象](#%E8%AE%BF%E9%97%AE%E5%88%9D%E5%A7%8B%E5%8C%96%E5%A5%BD%E7%9A%84-cyltabbarcontroller-%E5%AF%B9%E8%B1%A1)\n  - [点击 PlusButton 跳转到指定 UIViewController](#%E7%82%B9%E5%87%BB-plusbutton-%E8%B7%B3%E8%BD%AC%E5%88%B0%E6%8C%87%E5%AE%9A-uiviewcontroller)\n  - [让TabBarItem仅显示图标，并使图标垂直居中](#%E8%AE%A9tabbaritem%E4%BB%85%E6%98%BE%E7%A4%BA%E5%9B%BE%E6%A0%87%E5%B9%B6%E4%BD%BF%E5%9B%BE%E6%A0%87%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD)\n  - [多TabBar嵌套，并指定PlusButton位置](#%E5%A4%9Atabbar%E5%B5%8C%E5%A5%97%E5%B9%B6%E6%8C%87%E5%AE%9Aplusbutton%E4%BD%8D%E7%BD%AE)\n  - [在 Swift 项目中使用 CYLTabBarController](#%E5%9C%A8-swift-%E9%A1%B9%E7%9B%AE%E4%B8%AD%E4%BD%BF%E7%94%A8-cyltabbarcontroller)\n  - [搭配 Storyboard 使用 CYLTabBarController](#%E6%90%AD%E9%85%8D-storyboard-%E4%BD%BF%E7%94%A8-cyltabbarcontroller)\n  - [源码实现原理](#%E6%BA%90%E7%A0%81%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86)\n- [FAQ](#faq)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n\n## 与其他自定义TabBarController的区别\n## Comparetion with other Libraries\n\n[CN]特点 \u003c/p\u003e[EN]Features |[CN]解释 \u003c/p\u003e[EN]Explanation\n:-------------:|:-------------:\n[CN]一行代码支持Lottie动画TabBar样式 \u003c/p\u003e [EN] It only needs one line of code to have an animated TabBar with Lottie. |[CN][使用方法]( https://github.com/ChenYilong/CYLTabBarController/issues/341) \u003c/p\u003e  [EN][How to add animation of Lottie with one line of code.]( https://github.com/ChenYilong/CYLTabBarController/issues/341)  \u003c/p\u003e ![https://github.com/ChenYilong](https://tva1.sinaimg.cn/large/006y8mN6ly1g6upmqhqjrg30o209r4qp.gif) \u003c/p\u003e  ![https://github.com/ChenYilong](https://tva1.sinaimg.cn/large/006y8mN6ly1g6uqohfiw2g30cd03hdop.gif)\n[CN]低耦合，易删除\u003c/p\u003e[EN]Loose coupling  | [CN]1、TabBar设置与业务完全分离，最低只需传两个数组即可完成主流App框架搭建。\u003c/p\u003e[EN]1. This library is independent of your business codes which only needs two array parameters to be passed.   \u003c/p\u003e [CN]2、 PlusButton 的所有设置都在单独的一个类（ `CYLPlusButton` 的子类）中实现：删除该特定的类，就能完全将 PlusButton 从项目中删除掉。\u003c/p\u003e[EN]2.PlusButton is also independent. If you delete the code of this class, you remove the PlusButton feature from your UI on screen completely.  \n[CN]`TabBar` 以及 `TabBar` 内的 `TabBarItem` 均使用系统原生的控件\u003c/p\u003e[EN]`TabBar` and `TabBarItem` those parts of this library both are system objects. | [CN]因为使用原生的控件，并非 `UIButton` 或 `UIView` 。好处如下：\u003c/p\u003e[EN]Advantages of quitting choosing `UIButton` or `UIView`: \u003c/p\u003e 1. 无需反复调“间距位置等”来接近系统效果。\u003c/p\u003e[EN]There is not need to adjust those object to make them close to a system  object appearance. \u003c/p\u003e 2. 在push到下一页时 `TabBar`  的隐藏和显示之间的过渡效果跟系统一致（详见“ [集成后的效果](https://github.com/ChenYilong/CYLTabBarController#集成后的效果) ”部分，给出了效果图）\u003c/p\u003e[EN]2. A push animation is same to a system objects appearance. \u003c/p\u003e 3. 原生控件，所以可以使用诸多系统API，比如：可以使用 ` [UITabBar appearance];` 、` [UITabBarItem appearance];` 设置样式。（详见“[补充说明](https://github.com/ChenYilong/CYLTabBarController#补充说明) ”部分，给出了响应代码示例）\u003c/p\u003e[EN]3.It is convenient to use the system API such as ` [UITabBar appearance];`,` [UITabBarItem appearance];`, etc.\n 自动监测是否需要添加“加号”按钮，\u003c/p\u003e并能自动设置位置\u003c/p\u003e[EN] It is able to check if need to add a PlusButton automatically. |[CYLTabBarController](https://github.com/ChenYilong/CYLTabBarController) 既支持类似微信的“中规中矩”的 `TabBarController` 样式，并且默认就是微信这种样式，同时又支持类似“微博”或“淘宝闲鱼”这种具有不规则加号按钮的 `TabBarController` 。想支持这种样式，只需自定义一个加号按钮，[CYLTabBarController](https://github.com/ChenYilong/CYLTabBarController) 能检测到它的存在并自动将 `tabBar` 排序好，无需多余操作，并且也预留了一定接口来满足自定义需求。\u003c/p\u003e“加号”按钮的样式、frame均在自定义的类中独立实现，不会涉及tabbar相关设置。\n  支持动态更新 | 可动态删除PlusButton ，可以动态更新样式 \u003c/p\u003e ![https://github.com/ChenYilong](https://tva1.sinaimg.cn/large/006y8mN6ly1g6uq38ulz8g30al02w0u1.gif)\n即使加号按钮超出了tabbar的区域，\u003c/p\u003e超出部分依然能响应点击事件 | 红线内的区域均能响应tabbar相关的点击事件，\u003c/p\u003e![https://github.com/ChenYilong](https://tva1.sinaimg.cn/large/006y8mN6ly1g6uqi6prqsj30j60g8js7.jpg)\n允许指定加号按钮位置 | 效果如下：\u003c/p\u003e![iTeaTime(技术清谈)](https://tva1.sinaimg.cn/large/006y8mN6gy1g92nics1hvj30a906u3ym.jpg) \u003c/p\u003eAirbnb-app效果：\u003c/p\u003e![iTeaTime(技术清谈)](https://tva1.sinaimg.cn/large/006y8mN6gy1g92nir57tmg308w0fsapi.gif)\n支持让 `TabBarItem` 仅显示图标，并自动使图标垂直居中，支持自定义TabBar高度 | 效果可见Airbnb-app效果，或者下图\u003c/p\u003e![enter image description here](https://cloud.githubusercontent.com/assets/7238866/10777333/5d7811c8-7d55-11e5-88be-8cb11bbeaf90.png)\n 支持角标自定义View | ![enter image description here](https://ws4.sinaimg.cn/large/006tKfTcly1fgl0yxcaboj30yi06at8t.jpg) \n 支持多TabBar嵌套，并指定PlusButton位置 | ![enter image description here](https://ws4.sinaimg.cn/large/006tNc79ly1fmn3005isfg308r0iltl6.gif)\n支持CocoaPods |容易集成\n支持Swift项目导入 | 兼容\n支持横竖屏 | －－\n\n\n\n\n（学习交流群：515295083）\n\n\n\n## 集成后的效果：\n既支持默认样式 | 同时也支持创建自定义的形状不规则加号按钮 \n-------------|------------\n![https://github.com/ChenYilong](https://tva1.sinaimg.cn/large/006y8mN6ly1g6uqwf0dm7j30ku048glt.jpg)| ![https://github.com/ChenYilong](https://tva1.sinaimg.cn/large/006y8mN6ly1g6uqwv5bptj30ku04a74i.jpg)\n\n\n 支持横竖屏\n \n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6ly1g6us68c57ig30fe0ggwj3.gif\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n本仓库配套Demo的效果：| [另一个Demo](https://github.com/ChenYilong/CYLTabBarControllerDemoForWeib) \u003c/p\u003e 使用CYLTabBarController实现了微博Tabbar框架，\u003c/p\u003e效果如下\n-------------|-------------\n![https://github.com/ChenYilong](https://tva1.sinaimg.cn/large/006y8mN6ly1g6usablffxg30ac0j1e81.gif) |  ![https://github.com/ChenYilong](https://tva1.sinaimg.cn/large/006y8mN6ly1g6usaqu6ulg30ac0j1ttj.gif)\n\n## 项目结构\n\n![https://github.com/ChenYilong](https://tva1.sinaimg.cn/large/006y8mN6ly1g6uqzog2wmj30ae0a8js5.jpg)\n\n做下说明：\n\n ```Objective-C\n\n├── CYLTabBarController  ＃核心库文件夹，如果不使用 CocoaPods 集成，请直接将这个文件夹拖拽带你的项目中\n└── Example\n    └── Classes\n        ├── Module       #模块类文件夹\n        │   ├── Home\n        │   ├── Message\n        │   ├── Mine\n        │   └── SameCity\n        └── View         #这里放着 CYLPlusButton 的子类 CYLPlusButtonSubclass，演示了如何创建自定义的形状不规则加号按钮\n        \n        \n ```\n\n\n## 使用[CYLTabBarController](https://github.com/ChenYilong/CYLTabBarController)\n\n四步完成主流App框架搭建：\n\n  1.  [ 第一步：使用CocoaPods导入CYLTabBarController ](https://github.com/ChenYilong/CYLTabBarController#第一步使用cocoapods导入cyltabbarcontroller) \n  2.  [第二步：设置CYLTabBarController的两个数组：控制器数组和TabBar属性数组](https://github.com/ChenYilong/CYLTabBarController#第二步设置cyltabbarcontroller的两个数组控制器数组和tabbar属性数组) \n  3.  [第三步：将CYLTabBarController设置为window的RootViewController](https://github.com/ChenYilong/CYLTabBarController#第三步将cyltabbarcontroller设置为window的rootviewcontroller) \n  4.  [第四步（可选）：创建自定义的形状不规则加号按钮](https://github.com/ChenYilong/CYLTabBarController#第四步可选创建自定义的形状不规则加号按钮) \n\n\n### 第一步：使用CocoaPods导入CYLTabBarController\n\n 1. CocoaPods 安装\n\n  如果您的机器上已经安装了 CocoaPods，直接进入下一步即可。\n\n  如果您的网络已经翻墙，在终端中运行如下命令直接安装：\n\n  ```\n  sudo gem install cocoapods\n  ```\n\n  如果您的网络不能翻墙，可以通过国内 Ruby China 的 RubyGems 镜像进行安装。\n\n  在终端依次运行以下命令：\n\n  ```\n  gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/\n  \n  sudo gem install cocoapods\n  ```\n\n 2. 查询 CocoaPods 源中的本库\n\n  在终端中运行以下命令：\n\n  ```\n  pod search CYLTabBarController\n  ```\n \n   这里注意，这个命令搜索的是本机上的最新版本，并没有联网查询。如果运行以上命令，没有搜到或者搜不到最新版本，您可以运行以下命令，更新一下您本地的 CocoaPods 源列表。\n\n  ```\n  pod repo update\n  ```\n \n 3. 使用 CocoaPods 导入\n\n  打开终端，进入到您的工程目录，执行以下命令，会自动生成一个 Podfile 文件。\n\n  ```\n  pod init\n  ```\n\n  然后使用 CocoaPods 进行安装。如果尚未安装 CocoaPods，运行以下命令进行安装：\n\n ```\n gem install cocoapods\n ```\n\n  打开 Podfile，在您项目的 target 下加入以下内容。（此处示例可能是旧版本，使用时请替换为最新版，最新版信息可以从这里获取：\u003ca href=\"https://github.com/ChenYilong/CYLTabBarController/blob/master/CYLTabBarController.podspec\"\u003e\u003cimg src=\"https://img.shields.io/badge/Pod-GetLatestVersion-green.svg?style=flat\"\u003e\u003c/a\u003e）\n\n  在文件 `Podfile` 中加入以下内容：\n\n ```\n pod 'CYLTabBarController', '~\u003e 1.24.0'\n ```\n\n  然后在终端中运行以下命令：\n\n ```\n pod install\n ```\n\n  或者这个命令：\n\n ```\n # 禁止升级 CocoaPods 的 spec 仓库，否则会卡在 Analyzing dependencies，非常慢\n pod update --verbose --no-repo-update\n ```\n\n  如果提示找不到库，则可去掉 `--no-repo-update`。\n\n  完成后1.24.0，CocoaPods 会在您的工程根目录下生成一个 `.xcworkspace` 文件。您需要通过此文件打开您的工程，而不是之前的 `.xcodeproj`。\n\n**CocoaPods 使用说明**\n\n**指定 CYLTabBarController 版本** \n\nCocoaPods 中，有几种设置 CYLTabBarController 版本的方法。如：\n\n`\u003e= 1.n.X` 会根据您本地的 CocoaPods 源列表，导入不低于 `1.(n+1).X` 版本的 CYLTabBarController。\n\n`~\u003e 1.n.X` 会根据您本地的 CocoaPods 源列表，介于 1.n.X~1.(n+1).0 之前版本的 CYLTabBarController。\n\n建议选择后者：锁定版本，便于团队开发。如：\n\n（此处示例可能是旧版本，使用时请替换为最新版，最新版信息可以从这里获取：\u003ca href=\"https://github.com/ChenYilong/CYLTabBarController/blob/master/CYLTabBarController.podspec\"\u003e\u003cimg src=\"https://img.shields.io/badge/Pod-GetLatestVersion-green.svg?style=flat\"\u003e\u003c/a\u003e）\n\n \n```\npod 'CYLTabBarController', '~\u003e 1.24.0'\n```\n\n\n - 升级本地 CocoaPods 源\n\n  `CocoaPods 有一个中心化的源，默认本地会缓存 CocoaPods 源服务器上的所有 CYLTabBarController 版本。\n\n 如果搜索的时候没有搜到或者搜不到最新版本，可以执行以下命令更新一下本地的缓存。\n\n ```\n pod repo update\n ```\n \n - 升级工程的 CYLTabBarController 版本\n\n 更新您工程目录中 Podfile 指定的 CYLTabBarController 版本后，在终端中执行以下命令。\n\n ```\n pod update\n ```\n\n\n - 清除 Cocoapods 本地缓存\n\n 特殊情况下，由于网络或者别的原因，通过 CocoaPods 下载的文件可能会有问题。\n\n 这时候您可以删除 CocoaPods 的缓存(~/Library/Caches/CocoaPods/Pods/Release 目录)，再次导入即可。\n\n - 查看当前使用的 CYLTabBarController 版本\n\n 您可以在 Podfile.lock 文件中看到您工程中使用的 CYLTabBarController 版本。\n\n 关于 CocoaPods 的更多内容，您可以参考 [CocoaPods 文档](https://cocoapods.org/)。\n\n\n###  第二步：设置CYLTabBarController的两个数组：控制器数组和TabBar属性数组\n\n ```Objective-C\n //MainTabBarController\n \n@interface MainTabBarController : CYLTabBarController\n@end\n\n\n- (instancetype)init {\n    if (!(self = [super init])) {\n        return nil;\n    }\n    /**\n     * 以下两行代码目的在于手动设置让TabBarItem只显示图标，不显示文字，并让图标垂直居中。\n     * 等效于在 `-tabBarItemsAttributesForController` 方法中不传 `CYLTabBarItemTitle` 字段。\n     * 更推荐后一种做法。\n     */\n    UIEdgeInsets imageInsets = UIEdgeInsetsZero;//UIEdgeInsetsMake(4.5, 0, -4.5, 0);\n    UIOffset titlePositionAdjustment = UIOffsetMake(0, -3.5);\n    CYLTabBarController *tabBarController = [CYLTabBarController tabBarControllerWithViewControllers:self.viewControllers\n                                                                               tabBarItemsAttributes:self.tabBarItemsAttributesForController\n                                                                                         imageInsets:imageInsets\n                                                                             titlePositionAdjustment:titlePositionAdjustment\n                                                                                             context:nil\n                                             ];\n    [self customizeTabBarAppearance:tabBarController];\n    self.navigationController.navigationBar.hidden = YES;\n    return (self = (MainTabBarController *)tabBarController);\n}\n\n- (NSArray *)viewControllers {\n    CYLHomeViewController *firstViewController = [[CYLHomeViewController alloc] init];\n    UIViewController *firstNavigationController = [[CYLBaseNavigationController alloc]\n                                                   initWithRootViewController:firstViewController];\n    [firstViewController cyl_setHideNavigationBarSeparator:YES];\n    CYLSameCityViewController *secondViewController = [[CYLSameCityViewController alloc] init];\n    UIViewController *secondNavigationController = [[CYLBaseNavigationController alloc]\n                                                    initWithRootViewController:secondViewController];\n    [secondViewController cyl_setHideNavigationBarSeparator:YES];\n    NSArray *viewControllers = @[\n                                 firstNavigationController,\n                                 secondNavigationController,\n                                 ];\n    return viewControllers;\n}\n\n- (NSArray *)tabBarItemsAttributesForController {\n    NSDictionary *firstTabBarItemsAttributes = @{\n                                                 CYLTabBarItemTitle : @\"首页\",\n                                                 CYLTabBarItemImage : self.darkMode ? @\"home_highlight\" : @\"home_normal\",  /* NSString and UIImage are supported*/\n                                                 CYLTabBarItemSelectedImage : @\"home_highlight\",  /* NSString and UIImage are supported*/\n                                                 };\n    NSDictionary *secondTabBarItemsAttributes = @{\n                                                  CYLTabBarItemTitle : @\"鱼塘\",\n                                                  CYLTabBarItemImage : self.darkMode ? @\"fishpond_highlight\" : @\"fishpond_normal\",\n                                                  CYLTabBarItemSelectedImage : @\"fishpond_highlight\",\n                                                  };\n    \n\n    NSArray *tabBarItemsAttributes = @[\n                                       firstTabBarItemsAttributes,\n                                       secondTabBarItemsAttributes,\n                                       ];\n    return tabBarItemsAttributes;\n}\n ```\n\n在这个字典中，`CYLTabBarItemImage` 和 `CYLTabBarItemSelectedImage` 支持 `NSString`、`UIImage`\n两种格式。`CYLTabBarItemTitle` 不设置将只展示图标，并会对布局作出居中处理。\n\n###  第三步：将CYLTabBarController设置为window的RootViewController\n\n\n ```Objective-C\n - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n /* *省略部分：   * */\n    [self.window setRootViewController:self.tabBarController];\n /* *省略部分：   * */\n    return YES;\n}\n ```\n \n或者将 CYLTabBarController 的子类设为 RootViewCOntroller ，也可以将CYLTabBarController子类的 NavigationViewController 作为 RootViewCOntroller，方便动态更新，Demo 中就是采用后者。\n\n\n###  第四步（可选）：创建自定义的形状不规则加号按钮\n\n\n创建一个继承于 CYLPlusButton 的类，要求和步骤：\n\n\n 1. 实现  `CYLPlusButtonSubclassing`  协议 \n\n 2. 子类将自身类型进行注册：调用 `[YourClass registerPlusButton]`，需要在 RootViewCOntroller 的 ViewDidLoad 中注册，也可以在 `-application:didFinishLaunchingWithOptions:` 方法里面操作。 \n\n   这里注意，不建议在子类的 `+load` 方法中调用，比如像下面这样做，在 iOS10 系统上有 Crash 的风险：\n\n ```Objective-C\n + (void)load {\n    [super registerPlusButton];\n }\n ```\n\n协议提供了可选方法：\n\n ```Objective-C\n+ (NSUInteger)indexOfPlusButtonInTabBar;\n+ (CGFloat)multiplierOfTabBarHeight:(CGFloat)tabBarHeight;\n+ (UIViewController *)plusChildViewController;\n+ (BOOL)shouldSelectPlusChildViewController;\n ```\n\n作用分别是：\n\n ```Objective-C\n + (NSUInteger)indexOfPlusButtonInTabBar;\n ```\n \n用来自定义加号按钮的位置，如果不实现默认居中，但是如果 `tabbar` 的个数是奇数则必须实现该方法，否则 `CYLTabBarController` 会抛出 `exception` 来进行提示。\n\n主要适用于如下情景：\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6gy1g92nics1hvj30a906u3ym.jpg\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\nAirbnb-app效果：\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6gy1g92nir57tmg308w0fsapi.gif\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n ```Objective-C\n+ (CGFloat)multiplierOfTabBarHeight:(CGFloat)tabBarHeight;\n ```\n\n该方法是为了调整自定义按钮中心点Y轴方向的位置，建议在按钮超出了 `tabbar` 的边界时实现该方法。返回值是自定义按钮中心点Y轴方向的坐标除以 `tabbar` 的高度，如果不实现，会自动进行比对，预设一个较为合适的位置，如果实现了该方法，预设的逻辑将失效。\n\n内部实现时，会使用该返回值来设置 PlusButton 的 centerY 坐标，公式如下：\n              \n`PlusButtonCenterY = multiplierOfTabBarHeight * taBarHeight + constantOfPlusButtonCenterYOffset;`\n\n也就是说：如果 constantOfPlusButtonCenterYOffset 为0，同时 multiplierOfTabBarHeight 的值是0.5，表示 PlusButton 居中，小于0.5表示 PlusButton 偏上，大于0.5则表示偏下。\n\n\n ```Objective-C\n+ (CGFloat)constantOfPlusButtonCenterYOffsetForTabBarHeight:(CGFloat)tabBarHeight;\n ```\n\n参考 `+multiplierOfTabBarHeight:` 中的公式：\n\n`PlusButtonCenterY = multiplierOfTabBarHeight * taBarHeight + constantOfPlusButtonCenterYOffset;`\n\n也就是说： constantOfPlusButtonCenterYOffset 大于0会向下偏移，小于0会向上偏移。\n\n注意：实现了该方法，但没有实现 `+multiplierOfTabBarHeight:` 方法，在这种情况下，会在预设逻辑的基础上进行偏移。\n\n详见Demo中的 `CYLPlusButtonSubclass` 类的实现。\n\n ```Objective-C\n+ (UIViewController *)plusChildViewController;\n ```\n\n详见： [点击 PlusButton 跳转到指定 UIViewController](https://github.com/ChenYilong/CYLTabBarController#点击-plusbutton-跳转到指定-uiviewcontroller) \n\n\n另外，如果加号按钮超出了边界，一般需要手动调用如下代码取消 tabbar 顶部默认的阴影，可在 AppDelegate 类中调用：\n\n\n ```Objective-C\n    //去除 TabBar 自带的顶部阴影\n    [[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];        \n ```\n\n// iOS10 后 需要使用 `-[CYLTabBarController hideTabBarShadowImageView]` 见 AppDelegate 类中的演示;\n\n如何调整、自定义 `PlusButton` 与其它 `TabBarItem` 的宽度？\n\n`CYLTabBarController` 规定：\n\n ```Objective-C\n TabBarItem 宽度 ＝  ( TabBar 总宽度 －  PlusButton 宽度  ) / (TabBarItem 个数)\n ```\n\n所以想自定义宽度，只需要修改 `PlusButton` 的宽度即可。\n\n比如你就可以在 Demo中的 `CYLPlusButtonSubclass.m` 类里：\n   \n把\n\n ```Objective-C\n [button sizeToFit]; \n ```\n\n改为\n\n ```Objective-C\n button.frame = CGRectMake(0.0, 0.0, 250, 100);\n button.backgroundColor = [UIColor redColor];\n ```\n\n效果如下，\n1.24.0\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6ly1g6ur17yxa3j30yi0c6abk.jpg\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n同时你也可以顺便测试下 `CYLTabBarController` 的这一个特性：\n\n \u003e 即使加号按钮超出了tabbar的区域，超出部分依然能响应点击事件\n\n并且你可以在项目中的任意位置读取到 `PlusButton` 的宽度，借助 `CYLTabBarController.h` 定义的 `CYLPlusButtonWidth` 这个extern。可参考 `+[CYLTabBarControllerConfig customizeTabBarAppearance:]` 里的用法。\n\n\n\n## 补充说明\n\n\n\n### 自定义 `TabBar` 样式\n\n如果想更进一步的自定义 `TabBar` 样式可在 `-application:didFinishLaunchingWithOptions:` 方法中设置\n\n ```Objective-C\n /**\n *  tabBarItem 的选中和不选中文字属性、背景图片\n */\n- (void)customizeInterface {\n    \n    // 普通状态下的文字属性\n    NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];\n    normalAttrs[NSForegroundColorAttributeName] = [UIColor grayColor];\n    \n    // 选中状态下的文字属性\n    NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];\n    selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];\n    \n    // 设置文字属性\n    UITabBarItem *tabBar = [UITabBarItem appearance];\n    [tabBar setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];\n    [tabBar setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];\n    \n    // 设置背景图片\n    UITabBar *tabBarAppearance = [UITabBar appearance];\n    [tabBarAppearance setBackgroundImage:[UIImage imageNamed:@\"tabbar_background\"]];\n}\n\n - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n /* *省略部分：   * */\n    [self.window makeKeyAndVisible];\n    [self customizeInterface];\n    return YES;\n}\n ```\n \n####  捕获 TabBar 点击事件\n\n实现 CYLTabBarController 的如下几个代理方法即可捕获点击事件。 \n  \n  下面这个方法能捕获当前点击的 `TabBar` 上的控件，可以是 `UITabBarButton`、也可以 `PlusButton`、也可以是添加到 `TabBar` 上的任意 `UIControl` 的子类。但是如果 `PlusButton` 也添加了点击事件，那么点击 `PlusButton` 将不会被触发这个代理方法。\n  \n ```Objective-C\n//CYLTabBarController.h\n\n@protocol CYLTabBarControllerDelegate \u003cNSObject\u003e\n\n/*!\n * @param tabBarController The tab bar controller containing viewController.\n * @param control Selected UIControl in TabBar.\n * @attention If PlusButton also add an action, then this delegate method will not be invoked when the PlusButton is selected.\n */\n- (void)tabBarController:(UITabBarController *)tabBarController didSelectControl:(UIControl *)control;\n\n@end\n\n ```\n\n 下面这个方法能捕获跳转前所在的控制器，以及跳转到的目标控制器。\n \n ```Objective-C\n//UITabBarController.h\n@protocol UITabBarControllerDelegate \u003cNSObject\u003e\n@optional\n- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController NS_AVAILABLE_IOS(3_0);\n@end\n\n ```\n\n注意：在调用该方法时应该始终调用\n`    [[self cyl_tabBarController] updateSelectionStatusIfNeededForTabBarController:tabBarController shouldSelectViewController:viewController];` 来确保 `PlusButton` 的选中状态。示例如下：\n\n ```Objective-C\n- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {\n    [[self cyl_tabBarController] updateSelectionStatusIfNeededForTabBarController:tabBarController shouldSelectViewController:viewController];\n    return YES;\n}\n ```\n\n相关用法已经在 Demo 中展示。\n\n 遵循协议的方式如下：\n \n \n ```Objective-C\n@interface AppDelegate ()\u003cUITabBarControllerDelegate, CYLTabBarControllerDelegate\u003e\n\n@end\n\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n    //...\n        tabBarControllerConfig.tabBarController.delegate = self;\n    //...\n    return YES;\n}\n ```\n\n###  点击 TabBarButton 时添加动画\n\nDemo 演示的效果图：\n\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://ww1.sinaimg.cn/large/006tNbRwly1fg9hu6qnwbg308v0gctcc.gif\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n实现如下代理方法，就能得到对应的选中控件，可以在控件上直接添加动画。\n\n\n ```Objective-C\n//CYLTabBarController.h\n\n@protocol CYLTabBarControllerDelegate \u003cNSObject\u003e\n\n/*!\n * @param tabBarController The tab bar controller containing viewController.\n * @param control Selected UIControl in TabBar.\n */\n- (void)tabBarController:(UITabBarController *)tabBarController didSelectControl:(UIControl *)control;\n\n@end\n\n ```\n \n Demo 中示例代码如下：\n\n 遵循协议\n \n \n ```Objective-C\n@interface AppDelegate ()\u003cUITabBarControllerDelegate, CYLTabBarControllerDelegate\u003e\n\n@end\n ```\n\n \n ```Objective-C\n //AppDelegate.m\n- (void)tabBarController:(UITabBarController *)tabBarController didSelectControl:(UIControl *)control {\n    UIView *animationView;\n    // 如果 PlusButton 也添加了点击事件，那么点击 PlusButton 后不会触发该代理方法。\n    if ([control isKindOfClass:[CYLExternPlusButton class]]) {\n        UIButton *button = CYLExternPlusButton;\n        animationView = button.imageView;\n    } else if ([control isKindOfClass:NSClassFromString(@\"UITabBarButton\")]) {\n        for (UIView *subView in control.subviews) {\n            if ([subView isKindOfClass:NSClassFromString(@\"UITabBarSwappableImageView\")]) {\n                animationView = subView;\n            }\n        }\n    }\n    \n    if ([self cyl_tabBarController].selectedIndex % 2 == 0) {\n        [self addScaleAnimationOnView:animationView];\n    } else {\n        [self addRotateAnimationOnView:animationView];\n    }\n}\n\n//缩放动画\n- (void)addScaleAnimationOnView:(UIView *)animationView {\n    //需要实现的帧动画，这里根据需求自定义\n    CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];\n    animation.keyPath = @\"transform.scale\";\n    animation.values = @[@1.0,@1.3,@0.9,@1.15,@0.95,@1.02,@1.0];\n    animation.duration = 1;\n    animation.calculationMode = kCAAnimationCubic;\n    [animationView.layer addAnimation:animation forKey:nil];\n}\n\n//旋转动画\n- (void)addRotateAnimationOnView:(UIView *)animationView {\n    [UIView animateWithDuration:0.32 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{\n        animationView.layer.transform = CATransform3DMakeRotation(M_PI, 0, 1, 0);\n    } completion:nil];\n    \n    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{\n        [UIView animateWithDuration:0.70 delay:0 usingSpringWithDamping:1 initialSpringVelocity:0.2 options:UIViewAnimationOptionCurveEaseOut animations:^{\n            animationView.layer.transform = CATransform3DMakeRotation(2 * M_PI, 0, 1, 0);\n        } completion:nil];\n    });\n}\n ```\n\n### 横竖屏适配\n\n`TabBar` 横竖屏适配时，如果你添加了 `PlusButton`，且适配时用到了 `TabBarItem` 的宽度, 不建议使用系统的`UIDeviceOrientationDidChangeNotification` , 请使用库里的 `CYLTabBarItemWidthDidChangeNotification` 来更新 `TabBar` 布局，最典型的场景就是，根据 `TabBarItem` 在不同横竖屏状态下的宽度变化来切换选中的`TabBarItem` 的背景图片。Demo 里 `CYLTabBarControllerConfig.m` 给出了这一场景的用法:\n\n\n `CYLTabBarController.h`  中提供了 `CYLTabBarItemWidth` 这一extern常量，并且会在 `TabBarItem` 的宽度发生变化时，及时更新该值，所以用法就如下所示：\n\n ```Objective-C\n- (void)updateTabBarCustomizationWhenTabBarItemWidthDidUpdate {\n    void (^deviceOrientationDidChangeBlock)(NSNotification *) = ^(NSNotification *notification) {\n        [self tabBarItemWidthDidUpdate];\n};\n    [[NSNotificationCenter defaultCenter] addObserverForName:CYLTabBarItemWidthDidChangeNotification\n                                                      object:nil\n                                                       queue:[NSOperationQueue mainQueue]\n                                                  usingBlock:deviceOrientationDidChangeBlock];\n}\n\n- (void)tabBarItemWidthDidUpdate {\n    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];\n    if ((orientation == UIDeviceOrientationLandscapeLeft) || (orientation == UIDeviceOrientationLandscapeRight)) {\n        NSLog(@\"Landscape Left or Right !\");\n    } else if (orientation == UIDeviceOrientationPortrait){\n        NSLog(@\"Landscape portrait!\");\n    }\n    CGSize selectionIndicatorImageSize = CGSizeMake(CYLTabBarItemWidth, [self cyl_tabBarController].tabBar.bounds.size.height);\n    [[self cyl_tabBarController].tabBar setSelectionIndicatorImage:[[self class]\n                                                                    imageFromColor:[UIColor yellowColor]\n                                                                    forSize:selectionIndicatorImageSize\n                                                                    withCornerRadius:0]];\n}\n ```\n \n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6ly1g6us68c57ig30fe0ggwj3.gif\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n\n### 访问初始化好的 CYLTabBarController 对象\n\n对于任意 `NSObject` 对象：\n\n `CYLTabBarController.h`  中为 `NSObject` 提供了分类方法 `-cyl_tabBarController` ，所以在任意对象中，一行代码就可以访问到一个初始化好的  `CYLTabBarController`  对象，`-cyl_tabBarController` 的作用你可以这样理解：与获取单例对象的  `+shareInstance` 方法作用一样。\n\n接口如下：\n\n ```Objective-C\n// CYLTabBarController.h\n\n@interface NSObject (CYLTabBarController)\n\n/**\n * If `self` is kind of `UIViewController`, this method will return the nearest ancestor in the view controller hierarchy that is a tab bar controller. If `self` is not kind of `UIViewController`, it will return the `rootViewController` of the `rootWindow` as long as you have set the `CYLTabBarController` as the  `rootViewController`. Otherwise return nil. (read-only)\n */\n@property (nonatomic, readonly) CYLTabBarController *cyl_tabBarController;\n\n@end\n ```\n\n用法：\n\n\n ```Objective-C\n//导入 CYLTabBarController.h\n#import \"CYLTabBarController.h\"\n\n- (void)viewDidLoad {\n    [super viewDidLoad];\n    CYLTabBarController *tabbarController = [self cyl_tabBarController];\n    /*...*/\n}\n ```\n\n###  点击 PlusButton 跳转到指定 UIViewController\n\n提供了一个协议方法来完成本功能：\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6ly1g6urdwrhhjj30mx0gjq5r.jpg\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n实现该方法后，能让 PlusButton 的点击效果与跟点击其他 TabBar 按钮效果一样，跳转到该方法指定的 UIViewController 。\n\n注意：必须同时实现 `+indexOfPlusButtonInTabBar` 来指定 PlusButton 的位置。\n\n遵循几个协议：\n\n\n ```Objective-C\n#pragma mark - CYLPlusButtonSubclassing\n\n+ (UIViewController *)plusChildViewController {\n    UIViewController *plusChildViewController = [[UIViewController alloc] init];\n    plusChildViewController.view.backgroundColor = [UIColor redColor];\n    plusChildViewController.navigationItem.title = @\"PlusChildViewController\";\n    UIViewController *plusChildNavigationController = [[UINavigationController alloc]\n                                                   initWithRootViewController:plusChildViewController];\n    return plusChildNavigationController;\n}\n\n+ (NSUInteger)indexOfPlusButtonInTabBar {\n    return 2;\n}\n\n+ (BOOL)shouldSelectPlusChildViewController {\n    BOOL isSelected = CYLExternPlusButton.selected;\n    if (isSelected) {\n//        HDLLogDebug(\"🔴类名与方法名：%@（在第%@行），描述：%@\", @(__PRETTY_FUNCTION__), @(__LINE__), @\"PlusButton is selected\");\n    } else {\n//        HDLLogDebug(\"🔴类名与方法名：%@（在第%@行），描述：%@\", @(__PRETTY_FUNCTION__), @(__LINE__), @\"PlusButton is not selected\");\n    }\n    return YES;\n}\n\n+ (CGFloat)multiplierOfTabBarHeight:(CGFloat)tabBarHeight {\n    return  0.3;\n}\n\n+ (CGFloat)constantOfPlusButtonCenterYOffsetForTabBarHeight:(CGFloat)tabBarHeight {\n    return (CYL_IS_IPHONE_X ? - 6 : 4);\n}\n\n//+ (NSString *)tabBarContext {\n//    return NSStringFromClass([self class]);\n//}\n\n ```\n\n\n另外你可以通过下面这个方法获取到 `PlusButton` 的点击事件：\n\n```Objective-C\n+ (BOOL)shouldSelectPlusChildViewController;\n```\n\n用法如下：\n\n\n```Objective-C\n+ (BOOL)shouldSelectPlusChildViewController {\n    BOOL isSelected = CYLExternPlusButton.selected;\n    if (isSelected) {\n        NSLog(@\"🔴类名与方法名：%@（在第%@行），描述：%@\", @(__PRETTY_FUNCTION__), @(__LINE__), @\"PlusButton is selected\");\n    } else {\n        NSLog(@\"🔴类名与方法名：%@（在第%@行），描述：%@\", @(__PRETTY_FUNCTION__), @(__LINE__), @\"PlusButton is not selected\");\n    }\n    return YES;\n}\n\n```\n\n### 让TabBarItem仅显示图标，并使图标垂直居中 \n\n要想实现该效果，只需要在设置 `tabBarItemsAttributes`该属性时不传 title 即可。\n\n比如：在Demo的基础上，注释掉图中红框部分：\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6ly1g6urbcuckkj30ly0erdil.jpg\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n注释前 | 注释后\n-------------|-------------\n![https://github.com/ChenYilong](https://tva1.sinaimg.cn/large/006y8mN6ly1g6urbvymxij30yi05g74r.jpg)|![https://github.com/ChenYilong](https://tva1.sinaimg.cn/large/006y8mN6ly1g6urc80bdoj30yi05iq3b.jpg)\n\n可以通过这种方式来达到 Airbnb-app 的效果：\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6gy1g92nir57tmg308w0fsapi.gif\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n如果想手动设置偏移量来达到该效果：\n可以在 `-setViewControllers:` 方法前设置 `CYLTabBarController` 的 `imageInsets` 和 `titlePositionAdjustment` 属性\n\n这里注意：设置这两个属性后，`TabBar` 中所有的 `TabBarItem` 都将被设置。并且第一种做法的逻辑将不会执行，也就是说该做法优先级要高于第一种做法。\n\n做法在demo中已经给出。\n\n但是想达到Airbnb-app的效果只有这个接口是不行的，还需要自定义下 `TabBar` 的高度，你需要设置 `CYLTabBarController` 的 `tabBarHeight` 属性。你可以在Demo的 `CYLTabBarControllerConfig.m` 中的 `-customizeTabBarAppearance:` 方法中设置。\n\n注：“仅显示图标，并使图标垂直居中”这里所指的“图标”，其所属的类是私有类： `UITabBarSwappableImageView`，所以 `CYLTabBarController` 在相关的接口命名时会包含 `SwappableImageView` 字样。另外，使用该特性需要 `pod update` 到 1.5.5以上的版本。\n\n\n### 多TabBar嵌套，并指定PlusButton位置 \n\n该功能旧版本可能并不支持，建议更新最新版中使用。\n\n效果图：\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://ws4.sinaimg.cn/large/006tNc79ly1fmn3005isfg308r0iltl6.gif\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n\n实现 PlusButton 的如下协议方法指定 context：\n\n ```Objective-C\n//CYLPlusButtonSubclassing\n+ (NSString *)tabBarContext;\n\n ```\n\n当该值与 TabBarController 的 context 能够匹配上，PlusButton 将会展示。如果 PlusButton 与 TabBarController 均未制定 context 值，那么默认 context 值是相等的。\n\n目前仅支持一个 PlusButton 展示一次，不限层级。如果与多个 TabBarController 的 context 能够匹配上，仅展示在最先一次的匹配上的 TabBarController 上。\n\n\n\n### 在 Swift 项目中使用 CYLTabBarController\n\n\n仓库中给出了一个Swift Demo，文件夹叫做 Example-Swift。\n\n如果想在Swift 项目中，将本库作为静态库使用：\n\nCocoaPods 1.5.0+ (with Xcode 9+)：\n\n ```Objective-C\n platform :ios, '8.0'\n# Uncomment the next line when you want all Pods as static framework\n# use_modular_headers!\npod 'CYLTabBarController', '~\u003e 1.29.0', :modular_headers =\u003e true\n ```\n\n\n作为动态库使用：\n\n ```Objective-C\nplatform :ios, '8.0'\nuse_frameworks!\n ```\n\n\n感谢[@WeMadeCode](https://github.com/WeMadeCode) 提供的 Swift 版 Demo，原仓库地址：[WeMadeCode/CYLTabBarController-Swift](https://github.com/WeMadeCode/CYLTabBarController-Swift) \n\n具体的编写步骤参考热心网友提供的教程： [《从头开始swift2.1 仿搜材通项目（三） 主流框架Tabbed的搭建》]( http://www.jianshu.com/p/c5bc2eae0f55?nomobile=yes ) \n\n这里注意，文章的早期一个版本的示例代码有问题（笔者注：现在已经更新了），少了设置 PlusButton 大小的代码：\n这将导致 PlusButton 点击事件失效，具体修改代码如下：\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6ly1g6ur43ri5uj30ko0jmdjc.jpg\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n### 搭配 Storyboard 使用 CYLTabBarController\n\n参考：\n\n - 见这里 [issue讨论]( https://github.com/ChenYilong/CYLTabBarController/issues/170 ) \n - [这里](https://github.com/ChenYilong/CYLDeallocBlockExecutor) ，里面有个文件夹CYLTabBarControllerTestDemo，这个Demo演示了如何搭配 Storyboard 使用。\n\n### 源码实现原理\n\n参考： [《[Note] CYLTabBarController》]( http://www.jianshu.com/p/8758d8014f86 ) \n\n更多文档信息可查看 [ ***CocoaDocs：CYLTabBarController*** ](http://cocoadocs.org/docsets/CYLTabBarController/1.2.1/index.html) 。\n\n## FAQ\n\n\n更多Q-A内容，可以在这里查看： [issue-FAQ](https://github.com/ChenYilong/CYLTabBarController/issues?utf8=✓\u0026q=+label%3AQ-A+) \nQ：为什么放置6个TabBarItem会显示异常？\n\nA：\n\nApple 规定：\n\n \u003e  一个 `TabBar` 上只能出现最多5个 `TabBarItem` ，第六个及更多的将不被显示。\n\n\n另外注意，Apple检测的是 `UITabBarItem` 及其子类，所以放置“加号按钮”，这是 `UIButton` 不在“5个”里面。\n\n最多只能添加5个 `TabBarItem` ，也就是说加上“加号按钮”，一共最多在一个 `TabBar` 上放置6个控件。否则第6个及之后出现 `TabBarItem` 会被自动屏蔽掉。而且就Apple的审核机制来说，超过5个也会被直接拒绝上架。\n\nQ：我把 demo 两侧的 item 各去掉一个后，按钮的响应区域就变成下图的样子了：\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://cloud.githubusercontent.com/assets/12152553/10725491/62600172-7c07-11e5-9e0a-0ec7d795d1e3.jpeg\"\u003e\u003c/a\u003e\u003c/p\u003e\n  \t\t  \n A：v1.5.5 版本已经修复了该问题，现在不会出现类似的问题了：点击按钮区域却不响应，响应区域有偏移。\n\nQ： 如何实现添加选中背景色的功能 ，像下面这样：\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://cloud.githubusercontent.com/assets/7238866/10777333/5d7811c8-7d55-11e5-88be-8cb11bbeaf90.png\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\nA：我已经在 Demo 中添加了如何实现该功能的代码：\n详情见 `CYLTabBarControllerConfig`  类中下面方法的实现：\n\n ```Objective-C\n/**\n *  更多TabBar自定义设置：比如：tabBarItem 的选中和不选中文字和背景图片属性、tabbar 背景图片属性\n */\n- (void)customizeTabBarAppearance:(CYLTabBarController *)tabBarController;\n\n ```\n\n效果如下：\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://cloud.githubusercontent.com/assets/2911921/10779397/34956b0a-7d6b-11e5-82d9-fa75aa34e8d0.png\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n\nQ: 当 `ViewController` 设置的 `self.title` 和 `tabBarItemsAttributes` 中对应的 `title` 不一致的时候，会出现如图的错误，排序不对了\n\nA：在 v1.0.7 版本中已经修复了该 bug，但是也需要注意：\n\n请勿使用 `self.title = @\"同城\";  ` 这种方式，请使用 `self.navigationItem.title = @\"同城\"; ` \n\n`self.title = @\"同城\";  ` 这种方式，如果和 `tabBarItemsAttributes` 中对应的 `title` 不一致的时候可能会导致如下现象（不算 bug，但看起来也很奇怪）：\n\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6ly1g6ur9yhnqej30ac01pq2z.jpg\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n\n规则如下：\n\n ```Objective-C\n\n    self.navigationItem.title = @\"同城\";    //✅sets navigation bar title.The right way to set the title of the navigation\n    self.tabBarItem.title = @\"同城\";   //❌sets tab bar title. Even the `tabBarItem.title` changed, this will be ignored in  tabbar.\n    self.title = @\"同城1\";                  //❌sets both of these. Do not do this‼️‼️ This may cause something strange like this : http://i68.tinypic.com/282l3x4.jpg \n\n ```\n\n Q :  当使用这个方法时 `-[UIViewController cyl_popSelectTabBarChildViewControllerAtIndex:]` 系列方法时，会出现如下的黑边问题。\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6ly1g6ur5d01x6j30af0ijmy6.jpg\"\u003e\u003c/a\u003e\u003c/p\u003e\n\nA： 这个是 iOS 系统的BUG，经测试iOS9.3已经修复了，如果在更早起版本中出现了，可以通过下面将 `rootWindow` 的背景色改为白色来避免：比如你可以 `Appdelegate` 类里这样设置：\n\n\n ```Objective-C\n//#import \"CYLTabBarController.h\"\n    [[self cyl_tabBarController] rootWindow].backgroundColor = [UIColor whiteColor];\n ```\nQ:我现在已经做好了一个比较简单的中间凸起的 icon 但是超过了49这个高度的位置是不能效应的  我想请问你的demo哪个功能是可以使我超出的范围也可以响应的呢?\n\nA: 这个是自动做的，但是 `CYLTabBarController` 只能保证的是：只要是 `UIButton` 的 frame 区域内就能响应。\n\n请把 button 的背景颜色设置为显眼的颜色，比如红色，比如像下面的plus按钮，红色部分是能接收点击事件的，但是超出了红色按钮的，黄色的图片区域，依然是无法响应点击事件的。\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw\"\u003e\u003cimg src=\"https://tva1.sinaimg.cn/large/006y8mN6ly1g6ur67tddnj30yi0c6abk.jpg\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n这是因为，在响应链上，`UIControl` 能响应点击事件， `UIImage` 无法响应。\n\n\nQ：为什么在iOS10上会Crash，iOS9上不会？\n\n\nA：\n  在注册加号按钮时，需要在 `-application:didFinishLaunchingWithOptions:` 方法里面调用 `[YourClass registerPlusButton]` \n\n   这里注意，不能在子类的 `+load` 方法中调用，比如像下面这样做，在 iOS10 系统上有 Crash 的风险：\n\n ```Objective-C\n + (void)load {\n    [super registerPlusButton];\n}\n ```\n\nQ: 我的样式是点击 `plusButton` 后跳转到一个 `ViewController`，但是选中了一次中间的 `plusButton` 之后，再点别的 `tabItem` ，中间不会变成 `normal` 的状态。\n\nA: 有两种情况会造成这个问题：\n\n 1.  应该是你的 `tabBar` 设置了 `delegate` 了，你要是 `tabBar` 的代理没设置的话，默认会有这个 `selected` 状态切换的处理。你设置代理后，会覆盖我的行为。所以手动加上就好了。\n\n ```Objective-C\n- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {\n    [[self cyl_tabBarController] updateSelectionStatusIfNeededForTabBarController:tabBarController shouldSelectViewController:viewController];\n    return YES;\n}\n ```\n\n 2. `plusButton` 添加了自定义点击事件或者自定义手势，因为这样会造成点击事件冲突或手势冲突，当需要 `pushViewController` 的时候，这个库会自动的添加点击事件，你这里重新加了点击事件所以冲突了；\n\n 在你项目的基础，把 `plusButton` 的点击事件取消掉,也就是 `addTarget` 这一行注释掉，手势事件也同理，应该就ok了\n\nA: `PlusButton` 与其他的 `TabBarItem` 距离没有平均分布 \n\n(对应于 [issue#36](https://github.com/ChenYilong/CYLTabBarController/issues/36#issuecomment-269165471) )\n\n把这 Demo 里的这一行代码改下：\n\n ```Objective-C\n[button sizeToFit];\n ```\n\n改成：\n\n ```Objective-C\nbutton.frame = CGRectMake(0.0, 0.0, w, h);\n ```\n\n那么如果单是放一个照相机的图片，一般是多大的尺寸？\n\n这个要看设计图，通常情况下，你可以写死与其他TabBarItem一样大小：\n\n\n ```Objective-C\n [UIScreen mainScreen].bounds.size.width / [CYLTabBarController allItemsInTabBarCount]\n ```\n \n \nQ：如何兼容 Lottie 动画？\nA：用法见：https://github.com/ChenYilong/CYLTabBarController/issues/341\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=ChenYilong/CYLTabBarController\u0026type=Date)](https://star-history.com/#ChenYilong/CYLTabBarController\u0026Date)\n\n\n（更多iOS开发干货，欢迎关注  [微博@iOS程序犭袁](http://weibo.com/luohanchenyilong/) ）\n \n\n--------------------------------------------\n\n\nPosted by Posted by [微博@iOS程序犭袁](http://weibo.com/luohanchenyilong/) \u0026 [公众号@iTeaTime技术清谈](https://mp.weixin.qq.com/s/A4e5h3xgIEh6PInf1Rjqsw) \n原创作品，版权声明：License MIT\n\u003cp align=\"center\"\u003e\u003ca href=\"http://weibo.com/u/1692391497?s=6uyXnP\" target=\"_blank\"\u003e\u003cimg border=\"0\" src=\"http://service.t.sina.com.cn/widget/qmd/1692391497/b46c844b/1.png\"/\u003e\u003c/a\u003e\u003c/p\u003e\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenyilong%2Fcyltabbarcontroller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenyilong%2Fcyltabbarcontroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenyilong%2Fcyltabbarcontroller/lists"}