├── .gitignore ├── .swift-version ├── Classes ├── FriendVC.swift ├── MainVC.swift ├── MeVC.swift └── MsgVC.swift ├── DEMO.png ├── Image ├── find_tabbar@2x.png ├── find_tabbar@3x.png ├── find_tabbar_sel@2x.png ├── find_tabbar_sel@3x.png ├── friend_tabbar@2x.png ├── friend_tabbar@3x.png ├── friend_tabbar_sel@2x.png ├── friend_tabbar_sel@3x.png ├── home_tabbar@2x.png ├── home_tabbar@3x.png ├── home_tabbar_sel@2x.png ├── home_tabbar_sel@3x.png ├── me_tabbar@2x.png ├── me_tabbar@3x.png ├── me_tabbar_sel@2x.png ├── me_tabbar_sel@3x.png ├── msg_tabbar@2x.png ├── msg_tabbar@3x.png ├── msg_tabbar_sel@2x.png └── msg_tabbar_sel@3x.png ├── LICENSE ├── ProductName.png ├── README.md ├── README_注意.png ├── XHTabBarExampleSwift.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── xiaohui.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── xiaohui.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── XHTabBarExampleSwift.xcscheme │ └── xcschememanagement.plist ├── XHTabBarExampleSwift ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard └── Info.plist ├── XHTabBarSwift.podspec └── XHTabBarSwift └── XHTabBar.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | 6 | ## Build generated 7 | build/ 8 | DerivedData 9 | 10 | ## Various settings 11 | *.pbxuser 12 | !default.pbxuser 13 | *.mode1v3 14 | !default.mode1v3 15 | *.mode2v3 16 | !default.mode2v3 17 | *.perspectivev3 18 | !default.perspectivev3 19 | xcuserdata 20 | 21 | ## Other 22 | *.xccheckout 23 | *.moved-aside 24 | *.xcuserstate 25 | *.xcscmblueprint 26 | 27 | ## Obj-C/Swift specific 28 | *.hmap 29 | *.ipa 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | .build/ 37 | 38 | # Carthage 39 | Carthage/Build 40 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /Classes/FriendVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FriendVC.swift 3 | // XHTabBarExampleSwift 4 | // 5 | // Created by xiaohui on 16/8/8. 6 | // Copyright © 2016年 CoderZhuXH. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class FriendVC: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | self.navigationItem.title = "朋友" 17 | 18 | self.view.backgroundColor = ColorRandom()//随机色 19 | 20 | // Do any additional setup after loading the view. 21 | } 22 | 23 | override func didReceiveMemoryWarning() { 24 | super.didReceiveMemoryWarning() 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | 29 | /* 30 | // MARK: - Navigation 31 | 32 | // In a storyboard-based application, you will often want to do a little preparation before navigation 33 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 34 | // Get the new view controller using segue.destinationViewController. 35 | // Pass the selected object to the new view controller. 36 | } 37 | */ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Classes/MainVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainVC.swift 3 | // XHTabBarExampleSwift 4 | // 5 | // Created by xiaohui on 16/8/8. 6 | // Copyright © 2016年 CoderZhuXH. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MainVC: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | self.navigationItem.title = "首页" 17 | 18 | self.view.backgroundColor = ColorRandom()//随机色 19 | 20 | self.view.addSubview(pushButton) 21 | 22 | // Do any additional setup after loading the view. 23 | } 24 | 25 | fileprivate lazy var pushButton:UIButton = { 26 | 27 | let button = UIButton(type: UIButtonType.custom) 28 | button.bounds = CGRect(x: 0,y: 0,width: 100,height: 40) 29 | button.center = self.view.center 30 | button.setTitle("Push", for: UIControlState()) 31 | button.backgroundColor = UIColor.orange 32 | button.addTarget(self, action:#selector(MainVC.pushAction), for: UIControlEvents.touchUpInside) 33 | return button; 34 | }() 35 | 36 | @objc fileprivate func pushAction() 37 | { 38 | 39 | let controller = UIViewController.init() 40 | controller.view.backgroundColor = ColorRandom()//随机色 41 | controller.hidesBottomBarWhenPushed = true 42 | self.navigationController?.pushViewController(controller, animated: true) 43 | 44 | } 45 | 46 | override func didReceiveMemoryWarning() { 47 | super.didReceiveMemoryWarning() 48 | // Dispose of any resources that can be recreated. 49 | } 50 | 51 | 52 | /* 53 | // MARK: - Navigation 54 | 55 | // In a storyboard-based application, you will often want to do a little preparation before navigation 56 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 57 | // Get the new view controller using segue.destinationViewController. 58 | // Pass the selected object to the new view controller. 59 | } 60 | */ 61 | 62 | } 63 | -------------------------------------------------------------------------------- /Classes/MeVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MeVC.swift 3 | // XHTabBarExampleSwift 4 | // 5 | // Created by xiaohui on 16/8/8. 6 | // Copyright © 2016年 CoderZhuXH. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MeVC: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | self.navigationItem.title = "我的" 17 | 18 | self.view.backgroundColor = ColorRandom()//随机色 19 | 20 | // Do any additional setup after loading the view. 21 | } 22 | 23 | override func didReceiveMemoryWarning() { 24 | super.didReceiveMemoryWarning() 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | 29 | /* 30 | // MARK: - Navigation 31 | 32 | // In a storyboard-based application, you will often want to do a little preparation before navigation 33 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 34 | // Get the new view controller using segue.destinationViewController. 35 | // Pass the selected object to the new view controller. 36 | } 37 | */ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Classes/MsgVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MsgVC.swift 3 | // XHTabBarExampleSwift 4 | // 5 | // Created by xiaohui on 16/8/8. 6 | // Copyright © 2016年 CoderZhuXH. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MsgVC: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | self.navigationItem.title = "消息" 17 | 18 | self.view.backgroundColor = ColorRandom()//随机色 19 | 20 | // Do any additional setup after loading the view. 21 | } 22 | 23 | override func didReceiveMemoryWarning() { 24 | super.didReceiveMemoryWarning() 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | 29 | /* 30 | // MARK: - Navigation 31 | 32 | // In a storyboard-based application, you will often want to do a little preparation before navigation 33 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 34 | // Get the new view controller using segue.destinationViewController. 35 | // Pass the selected object to the new view controller. 36 | } 37 | */ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /DEMO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/DEMO.png -------------------------------------------------------------------------------- /Image/find_tabbar@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/find_tabbar@2x.png -------------------------------------------------------------------------------- /Image/find_tabbar@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/find_tabbar@3x.png -------------------------------------------------------------------------------- /Image/find_tabbar_sel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/find_tabbar_sel@2x.png -------------------------------------------------------------------------------- /Image/find_tabbar_sel@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/find_tabbar_sel@3x.png -------------------------------------------------------------------------------- /Image/friend_tabbar@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/friend_tabbar@2x.png -------------------------------------------------------------------------------- /Image/friend_tabbar@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/friend_tabbar@3x.png -------------------------------------------------------------------------------- /Image/friend_tabbar_sel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/friend_tabbar_sel@2x.png -------------------------------------------------------------------------------- /Image/friend_tabbar_sel@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/friend_tabbar_sel@3x.png -------------------------------------------------------------------------------- /Image/home_tabbar@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/home_tabbar@2x.png -------------------------------------------------------------------------------- /Image/home_tabbar@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/home_tabbar@3x.png -------------------------------------------------------------------------------- /Image/home_tabbar_sel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/home_tabbar_sel@2x.png -------------------------------------------------------------------------------- /Image/home_tabbar_sel@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/home_tabbar_sel@3x.png -------------------------------------------------------------------------------- /Image/me_tabbar@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/me_tabbar@2x.png -------------------------------------------------------------------------------- /Image/me_tabbar@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/me_tabbar@3x.png -------------------------------------------------------------------------------- /Image/me_tabbar_sel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/me_tabbar_sel@2x.png -------------------------------------------------------------------------------- /Image/me_tabbar_sel@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/me_tabbar_sel@3x.png -------------------------------------------------------------------------------- /Image/msg_tabbar@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/msg_tabbar@2x.png -------------------------------------------------------------------------------- /Image/msg_tabbar@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/msg_tabbar@3x.png -------------------------------------------------------------------------------- /Image/msg_tabbar_sel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/msg_tabbar_sel@2x.png -------------------------------------------------------------------------------- /Image/msg_tabbar_sel@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/Image/msg_tabbar_sel@3x.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 XHTabBarSwift (https://github.com/CoderZhuXH/XHTabBarSwift) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProductName.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/ProductName.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # XHTabBarSwift 3 | 4 | #### 一行代码创建自定义TabBar,支持小红点,数字角标及自定义高度 5 | 6 | [![AppVeyor](https://img.shields.io/appveyor/ci/gruntjs/grunt.svg?maxAge=2592000)](https://github.com/CoderZhuXH/XHTabBarSwift) 7 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/CoderZhuXH/XHTabBarSwift) 8 | [![Version Status](https://img.shields.io/cocoapods/v/XHTabBarSwift.svg?style=flat)](http://cocoadocs.org/docsets/XHTabBarSwift) 9 | ![Support](https://img.shields.io/badge/support-iOS%208%2B-brightgreen.svg) 10 | [![Pod Platform](https://img.shields.io/cocoapods/p/XHTabBarSwift.svg?style=flat)](http://cocoadocs.org/docsets/XHTabBarSwift) 11 | [![Pod License](https://img.shields.io/cocoapods/l/XHTabBarSwift.svg?style=flat)](https://github.com/CoderZhuXH/XHTabBarSwift/blob/master/LICENSE) 12 | 13 | ============== 14 | 15 | #### OC版请戳这里>>> https://github.com/CoderZhuXH/XHTabBar 16 | 17 | ###技术交流群(群号:537476189). 18 | ## 效果 19 | ![image](https://raw.githubusercontent.com/CoderZhuXH/XHTabBar/master/DEMO.PNG) 20 | 21 | ## 使用方法 22 | ### 1.在Appdelegate 中初始化,并设置为根控制器 23 | ```swift 24 | /* 25 | 控制器name数组 26 | */ 27 | let controllerArray = ["MainVC","MsgVC","FriendVC","MeVC"] 28 | /* 29 | title数组 30 | */ 31 | let titleArray = ["首页","消息","朋友","我的"] 32 | /* 33 | 默认图片数组 34 | */ 35 | let imageArray = ["home_tabbar","msg_tabbar","friend_tabbar","me_tabbar"] 36 | /* 37 | 选中图片数组 38 | */ 39 | let selImageArray = ["home_tabbar_sel","msg_tabbar_sel","friend_tabbar_sel","me_tabbar_sel"] 40 | /* 41 | tabbar高度最小值49.0, 传nil或<49.0均按49.0处理 42 | */ 43 | let height = CGFloat(49) 44 | 45 | /* 46 | 创建tabBarController 47 | */ 48 | let tabBarController = XHTabBar(controllerArray:controllerArray,titleArray: titleArray,imageArray: imageArray,selImageArray: selImageArray,height:height) 49 | 50 | /* 51 | 设置为根控制器 52 | */ 53 | window?.rootViewController = tabBarController 54 | ``` 55 | ### 2.影藏tabBar 56 | ```swift 57 | /* 58 | push界面时,影藏tabBar,如下 59 | */ 60 | let controller = UIViewController.init() 61 | controller.hidesBottomBarWhenPushed = true 62 | self.navigationController?.pushViewController(controller, animated: true) 63 | ``` 64 | ### 3.角标、小红点及其他设置接口 65 | ```swift 66 | 67 | /** 68 | * 手动切换显示到指定控制器 69 | * 70 | * - param: index 位置 71 | */ 72 | public func showControllerIndex(_ index: Int) 73 | 74 | /** 75 | * 设置数字角标 76 | * 77 | * - param: num 所要显示数字 78 | * - param: index 位置 79 | */ 80 | public func showBadgeMark(_ badge:: Int, index: Int) 81 | 82 | /** 83 | * 设置小红点 84 | * 85 | * - param: index 位置 86 | */ 87 | public func showPointMarkIndex(_ index: Int) 88 | 89 | /** 90 | * 影藏指定位置角标 91 | * 92 | * - param: index 位置 93 | */ 94 | public func hideMarkIndex(_ index: Int) 95 | 96 | ``` 97 | ### 4.定义tabbar文字大小,颜色,请在XHTabBar.m 顶部修改下面值即可 98 | ```swift 99 | /** 100 | * tabbar背景色 101 | */ 102 | private let ColorTabBar = UIColor.white 103 | 104 | /** 105 | * title默认颜色 106 | */ 107 | private let ColorTitle = UIColor.gray 108 | 109 | /** 110 | * title选中颜色 111 | */ 112 | private let ColorTitleSel = ColorRGB(41,g: 167,b: 245) 113 | 114 | /** 115 | * title字体大小 116 | */ 117 | private let titleFontSize : CGFloat = 12.0 118 | 119 | /** 120 | * 数字角标直径 121 | */ 122 | private let numMarkD:CGFloat = 20.0 123 | 124 | /** 125 | * 小红点直径 126 | */ 127 | private let pointMarkD:CGFloat = 12.0 128 | 129 | /** 130 | * button 图片与文字上下占比 131 | */ 132 | private let scale:CGFloat = 0.55 133 | 134 | 135 | ``` 136 | ## 安装 137 | ### 手动添加:
138 | * 1.将 XHTabBar 文件夹添加到工程目录中
139 | 140 | ### CocoaPods:
141 | * 1.在 Podfile 中添加 pod 'XHTabBarSwift'
142 | * 2.执行 pod install 或 pod update
143 | * 3.导入 import XHTabBarSwift 144 | 145 | ### Tips 146 | * 1.如果发现pod search XHTabBarSwift 搜索出来的不是最新版本,需要在终端执行cd desktop退回到desktop,然后执行pod setup命令更新本地spec缓存(需要几分钟),然后再搜索就可以了 147 | * 2.如果你发现你执行pod install后,导入的不是最新版本,请删除Podfile.lock文件,在执行一次 pod install 148 | 149 | ## 注意 150 | * 该项目通过 `动态获取命名空间` + `.` + `类名` 来创建类对象,如下: 151 | ```swift 152 | let cls: AnyClass? = NSClassFromString(命名空间 + "." + 类名) 153 | ``` 154 | * 实测中发现,当命名空间为非全英文 或含有 ` - ` 等特殊字符时 创建类对象会为 `nil` 155 | * 1.项目命名空间默认为项目名称.
156 | 2.当碰到类名称正确 创建类对象失败(即`报error:cls不能当做UIViewController错误时`)时,可以到TARGETS -> Build Settings ->Produce Name 中修改命名空间为全英文,并去掉命名空间中 ` - ` 等特殊字符: 157 | ![image](https://github.com/CoderZhuXH/XHTabBarSwift/blob/master/ProductName.png) 158 | 159 | ## 系统要求 160 | * 该项目最低支持 iOS 8.0 和 Xcode 8.0 161 | 162 | ## 许可证 163 | XHTabBarSwift 使用 MIT 许可证,详情见 LICENSE 文件 164 | -------------------------------------------------------------------------------- /README_注意.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/README_注意.png -------------------------------------------------------------------------------- /XHTabBarExampleSwift.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4B2A72B91D5826B1006A1C65 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A72B81D5826B1006A1C65 /* AppDelegate.swift */; }; 11 | 4B2A72C01D5826B1006A1C65 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72BF1D5826B1006A1C65 /* Assets.xcassets */; }; 12 | 4B2A72C31D5826B1006A1C65 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72C11D5826B1006A1C65 /* LaunchScreen.storyboard */; }; 13 | 4B2A72E61D5826E1006A1C65 /* FriendVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A72CB1D5826E1006A1C65 /* FriendVC.swift */; }; 14 | 4B2A72E71D5826E1006A1C65 /* MainVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A72CC1D5826E1006A1C65 /* MainVC.swift */; }; 15 | 4B2A72E81D5826E1006A1C65 /* MeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A72CD1D5826E1006A1C65 /* MeVC.swift */; }; 16 | 4B2A72E91D5826E1006A1C65 /* MsgVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A72CE1D5826E1006A1C65 /* MsgVC.swift */; }; 17 | 4B2A72EB1D5826E1006A1C65 /* find_tabbar@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72D21D5826E1006A1C65 /* find_tabbar@2x.png */; }; 18 | 4B2A72EC1D5826E1006A1C65 /* find_tabbar@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72D31D5826E1006A1C65 /* find_tabbar@3x.png */; }; 19 | 4B2A72ED1D5826E1006A1C65 /* find_tabbar_sel@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72D41D5826E1006A1C65 /* find_tabbar_sel@2x.png */; }; 20 | 4B2A72EE1D5826E1006A1C65 /* find_tabbar_sel@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72D51D5826E1006A1C65 /* find_tabbar_sel@3x.png */; }; 21 | 4B2A72EF1D5826E1006A1C65 /* friend_tabbar@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72D61D5826E1006A1C65 /* friend_tabbar@2x.png */; }; 22 | 4B2A72F01D5826E1006A1C65 /* friend_tabbar@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72D71D5826E1006A1C65 /* friend_tabbar@3x.png */; }; 23 | 4B2A72F11D5826E1006A1C65 /* friend_tabbar_sel@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72D81D5826E1006A1C65 /* friend_tabbar_sel@2x.png */; }; 24 | 4B2A72F21D5826E1006A1C65 /* friend_tabbar_sel@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72D91D5826E1006A1C65 /* friend_tabbar_sel@3x.png */; }; 25 | 4B2A72F31D5826E1006A1C65 /* home_tabbar@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72DA1D5826E1006A1C65 /* home_tabbar@2x.png */; }; 26 | 4B2A72F41D5826E1006A1C65 /* home_tabbar@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72DB1D5826E1006A1C65 /* home_tabbar@3x.png */; }; 27 | 4B2A72F51D5826E1006A1C65 /* home_tabbar_sel@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72DC1D5826E1006A1C65 /* home_tabbar_sel@2x.png */; }; 28 | 4B2A72F61D5826E1006A1C65 /* home_tabbar_sel@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72DD1D5826E1006A1C65 /* home_tabbar_sel@3x.png */; }; 29 | 4B2A72F71D5826E1006A1C65 /* me_tabbar@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72DE1D5826E1006A1C65 /* me_tabbar@2x.png */; }; 30 | 4B2A72F81D5826E1006A1C65 /* me_tabbar@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72DF1D5826E1006A1C65 /* me_tabbar@3x.png */; }; 31 | 4B2A72F91D5826E1006A1C65 /* me_tabbar_sel@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72E01D5826E1006A1C65 /* me_tabbar_sel@2x.png */; }; 32 | 4B2A72FA1D5826E1006A1C65 /* me_tabbar_sel@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72E11D5826E1006A1C65 /* me_tabbar_sel@3x.png */; }; 33 | 4B2A72FB1D5826E1006A1C65 /* msg_tabbar@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72E21D5826E1006A1C65 /* msg_tabbar@2x.png */; }; 34 | 4B2A72FC1D5826E1006A1C65 /* msg_tabbar@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72E31D5826E1006A1C65 /* msg_tabbar@3x.png */; }; 35 | 4B2A72FD1D5826E1006A1C65 /* msg_tabbar_sel@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72E41D5826E1006A1C65 /* msg_tabbar_sel@2x.png */; }; 36 | 4B2A72FE1D5826E1006A1C65 /* msg_tabbar_sel@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2A72E51D5826E1006A1C65 /* msg_tabbar_sel@3x.png */; }; 37 | 4B7C87A71D6195820099E1FA /* XHTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B7C87A61D6195820099E1FA /* XHTabBar.swift */; }; 38 | /* End PBXBuildFile section */ 39 | 40 | /* Begin PBXFileReference section */ 41 | 4B2A72B51D5826B1006A1C65 /* XHTabBarExampleSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = XHTabBarExampleSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 4B2A72B81D5826B1006A1C65 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 43 | 4B2A72BF1D5826B1006A1C65 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 44 | 4B2A72C21D5826B1006A1C65 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 45 | 4B2A72C41D5826B1006A1C65 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | 4B2A72CB1D5826E1006A1C65 /* FriendVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FriendVC.swift; sourceTree = ""; }; 47 | 4B2A72CC1D5826E1006A1C65 /* MainVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainVC.swift; sourceTree = ""; }; 48 | 4B2A72CD1D5826E1006A1C65 /* MeVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MeVC.swift; sourceTree = ""; }; 49 | 4B2A72CE1D5826E1006A1C65 /* MsgVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MsgVC.swift; sourceTree = ""; }; 50 | 4B2A72D21D5826E1006A1C65 /* find_tabbar@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "find_tabbar@2x.png"; sourceTree = ""; }; 51 | 4B2A72D31D5826E1006A1C65 /* find_tabbar@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "find_tabbar@3x.png"; sourceTree = ""; }; 52 | 4B2A72D41D5826E1006A1C65 /* find_tabbar_sel@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "find_tabbar_sel@2x.png"; sourceTree = ""; }; 53 | 4B2A72D51D5826E1006A1C65 /* find_tabbar_sel@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "find_tabbar_sel@3x.png"; sourceTree = ""; }; 54 | 4B2A72D61D5826E1006A1C65 /* friend_tabbar@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "friend_tabbar@2x.png"; sourceTree = ""; }; 55 | 4B2A72D71D5826E1006A1C65 /* friend_tabbar@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "friend_tabbar@3x.png"; sourceTree = ""; }; 56 | 4B2A72D81D5826E1006A1C65 /* friend_tabbar_sel@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "friend_tabbar_sel@2x.png"; sourceTree = ""; }; 57 | 4B2A72D91D5826E1006A1C65 /* friend_tabbar_sel@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "friend_tabbar_sel@3x.png"; sourceTree = ""; }; 58 | 4B2A72DA1D5826E1006A1C65 /* home_tabbar@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "home_tabbar@2x.png"; sourceTree = ""; }; 59 | 4B2A72DB1D5826E1006A1C65 /* home_tabbar@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "home_tabbar@3x.png"; sourceTree = ""; }; 60 | 4B2A72DC1D5826E1006A1C65 /* home_tabbar_sel@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "home_tabbar_sel@2x.png"; sourceTree = ""; }; 61 | 4B2A72DD1D5826E1006A1C65 /* home_tabbar_sel@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "home_tabbar_sel@3x.png"; sourceTree = ""; }; 62 | 4B2A72DE1D5826E1006A1C65 /* me_tabbar@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "me_tabbar@2x.png"; sourceTree = ""; }; 63 | 4B2A72DF1D5826E1006A1C65 /* me_tabbar@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "me_tabbar@3x.png"; sourceTree = ""; }; 64 | 4B2A72E01D5826E1006A1C65 /* me_tabbar_sel@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "me_tabbar_sel@2x.png"; sourceTree = ""; }; 65 | 4B2A72E11D5826E1006A1C65 /* me_tabbar_sel@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "me_tabbar_sel@3x.png"; sourceTree = ""; }; 66 | 4B2A72E21D5826E1006A1C65 /* msg_tabbar@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "msg_tabbar@2x.png"; sourceTree = ""; }; 67 | 4B2A72E31D5826E1006A1C65 /* msg_tabbar@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "msg_tabbar@3x.png"; sourceTree = ""; }; 68 | 4B2A72E41D5826E1006A1C65 /* msg_tabbar_sel@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "msg_tabbar_sel@2x.png"; sourceTree = ""; }; 69 | 4B2A72E51D5826E1006A1C65 /* msg_tabbar_sel@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "msg_tabbar_sel@3x.png"; sourceTree = ""; }; 70 | 4B7C87A61D6195820099E1FA /* XHTabBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XHTabBar.swift; sourceTree = ""; }; 71 | /* End PBXFileReference section */ 72 | 73 | /* Begin PBXFrameworksBuildPhase section */ 74 | 4B2A72B21D5826B1006A1C65 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | 4B2A72AC1D5826B0006A1C65 = { 85 | isa = PBXGroup; 86 | children = ( 87 | 4B2A72CA1D5826E1006A1C65 /* Classes */, 88 | 4B7C87A51D6195820099E1FA /* XHTabBarSwift */, 89 | 4B2A72D11D5826E1006A1C65 /* Image */, 90 | 4B2A72B71D5826B1006A1C65 /* XHTabBarExampleSwift */, 91 | 4B2A72B61D5826B1006A1C65 /* Products */, 92 | ); 93 | sourceTree = ""; 94 | }; 95 | 4B2A72B61D5826B1006A1C65 /* Products */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 4B2A72B51D5826B1006A1C65 /* XHTabBarExampleSwift.app */, 99 | ); 100 | name = Products; 101 | sourceTree = ""; 102 | }; 103 | 4B2A72B71D5826B1006A1C65 /* XHTabBarExampleSwift */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 4B2A72B81D5826B1006A1C65 /* AppDelegate.swift */, 107 | 4B2A72BF1D5826B1006A1C65 /* Assets.xcassets */, 108 | 4B2A72C11D5826B1006A1C65 /* LaunchScreen.storyboard */, 109 | 4B2A72C41D5826B1006A1C65 /* Info.plist */, 110 | ); 111 | path = XHTabBarExampleSwift; 112 | sourceTree = ""; 113 | }; 114 | 4B2A72CA1D5826E1006A1C65 /* Classes */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 4B2A72CC1D5826E1006A1C65 /* MainVC.swift */, 118 | 4B2A72CB1D5826E1006A1C65 /* FriendVC.swift */, 119 | 4B2A72CD1D5826E1006A1C65 /* MeVC.swift */, 120 | 4B2A72CE1D5826E1006A1C65 /* MsgVC.swift */, 121 | ); 122 | path = Classes; 123 | sourceTree = ""; 124 | }; 125 | 4B2A72D11D5826E1006A1C65 /* Image */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 4B2A72D21D5826E1006A1C65 /* find_tabbar@2x.png */, 129 | 4B2A72D31D5826E1006A1C65 /* find_tabbar@3x.png */, 130 | 4B2A72D41D5826E1006A1C65 /* find_tabbar_sel@2x.png */, 131 | 4B2A72D51D5826E1006A1C65 /* find_tabbar_sel@3x.png */, 132 | 4B2A72D61D5826E1006A1C65 /* friend_tabbar@2x.png */, 133 | 4B2A72D71D5826E1006A1C65 /* friend_tabbar@3x.png */, 134 | 4B2A72D81D5826E1006A1C65 /* friend_tabbar_sel@2x.png */, 135 | 4B2A72D91D5826E1006A1C65 /* friend_tabbar_sel@3x.png */, 136 | 4B2A72DA1D5826E1006A1C65 /* home_tabbar@2x.png */, 137 | 4B2A72DB1D5826E1006A1C65 /* home_tabbar@3x.png */, 138 | 4B2A72DC1D5826E1006A1C65 /* home_tabbar_sel@2x.png */, 139 | 4B2A72DD1D5826E1006A1C65 /* home_tabbar_sel@3x.png */, 140 | 4B2A72DE1D5826E1006A1C65 /* me_tabbar@2x.png */, 141 | 4B2A72DF1D5826E1006A1C65 /* me_tabbar@3x.png */, 142 | 4B2A72E01D5826E1006A1C65 /* me_tabbar_sel@2x.png */, 143 | 4B2A72E11D5826E1006A1C65 /* me_tabbar_sel@3x.png */, 144 | 4B2A72E21D5826E1006A1C65 /* msg_tabbar@2x.png */, 145 | 4B2A72E31D5826E1006A1C65 /* msg_tabbar@3x.png */, 146 | 4B2A72E41D5826E1006A1C65 /* msg_tabbar_sel@2x.png */, 147 | 4B2A72E51D5826E1006A1C65 /* msg_tabbar_sel@3x.png */, 148 | ); 149 | path = Image; 150 | sourceTree = ""; 151 | }; 152 | 4B7C87A51D6195820099E1FA /* XHTabBarSwift */ = { 153 | isa = PBXGroup; 154 | children = ( 155 | 4B7C87A61D6195820099E1FA /* XHTabBar.swift */, 156 | ); 157 | path = XHTabBarSwift; 158 | sourceTree = ""; 159 | }; 160 | /* End PBXGroup section */ 161 | 162 | /* Begin PBXNativeTarget section */ 163 | 4B2A72B41D5826B1006A1C65 /* XHTabBarExampleSwift */ = { 164 | isa = PBXNativeTarget; 165 | buildConfigurationList = 4B2A72C71D5826B1006A1C65 /* Build configuration list for PBXNativeTarget "XHTabBarExampleSwift" */; 166 | buildPhases = ( 167 | 4B2A72B11D5826B1006A1C65 /* Sources */, 168 | 4B2A72B21D5826B1006A1C65 /* Frameworks */, 169 | 4B2A72B31D5826B1006A1C65 /* Resources */, 170 | ); 171 | buildRules = ( 172 | ); 173 | dependencies = ( 174 | ); 175 | name = XHTabBarExampleSwift; 176 | productName = XHTabBarExampleSwift; 177 | productReference = 4B2A72B51D5826B1006A1C65 /* XHTabBarExampleSwift.app */; 178 | productType = "com.apple.product-type.application"; 179 | }; 180 | /* End PBXNativeTarget section */ 181 | 182 | /* Begin PBXProject section */ 183 | 4B2A72AD1D5826B0006A1C65 /* Project object */ = { 184 | isa = PBXProject; 185 | attributes = { 186 | LastSwiftUpdateCheck = 0730; 187 | LastUpgradeCheck = 0800; 188 | ORGANIZATIONNAME = qiantou; 189 | TargetAttributes = { 190 | 4B2A72B41D5826B1006A1C65 = { 191 | CreatedOnToolsVersion = 7.3.1; 192 | LastSwiftMigration = 0800; 193 | }; 194 | }; 195 | }; 196 | buildConfigurationList = 4B2A72B01D5826B0006A1C65 /* Build configuration list for PBXProject "XHTabBarExampleSwift" */; 197 | compatibilityVersion = "Xcode 3.2"; 198 | developmentRegion = English; 199 | hasScannedForEncodings = 0; 200 | knownRegions = ( 201 | en, 202 | Base, 203 | ); 204 | mainGroup = 4B2A72AC1D5826B0006A1C65; 205 | productRefGroup = 4B2A72B61D5826B1006A1C65 /* Products */; 206 | projectDirPath = ""; 207 | projectRoot = ""; 208 | targets = ( 209 | 4B2A72B41D5826B1006A1C65 /* XHTabBarExampleSwift */, 210 | ); 211 | }; 212 | /* End PBXProject section */ 213 | 214 | /* Begin PBXResourcesBuildPhase section */ 215 | 4B2A72B31D5826B1006A1C65 /* Resources */ = { 216 | isa = PBXResourcesBuildPhase; 217 | buildActionMask = 2147483647; 218 | files = ( 219 | 4B2A72C31D5826B1006A1C65 /* LaunchScreen.storyboard in Resources */, 220 | 4B2A72F61D5826E1006A1C65 /* home_tabbar_sel@3x.png in Resources */, 221 | 4B2A72F01D5826E1006A1C65 /* friend_tabbar@3x.png in Resources */, 222 | 4B2A72C01D5826B1006A1C65 /* Assets.xcassets in Resources */, 223 | 4B2A72ED1D5826E1006A1C65 /* find_tabbar_sel@2x.png in Resources */, 224 | 4B2A72F51D5826E1006A1C65 /* home_tabbar_sel@2x.png in Resources */, 225 | 4B2A72FC1D5826E1006A1C65 /* msg_tabbar@3x.png in Resources */, 226 | 4B2A72F81D5826E1006A1C65 /* me_tabbar@3x.png in Resources */, 227 | 4B2A72FE1D5826E1006A1C65 /* msg_tabbar_sel@3x.png in Resources */, 228 | 4B2A72EF1D5826E1006A1C65 /* friend_tabbar@2x.png in Resources */, 229 | 4B2A72F91D5826E1006A1C65 /* me_tabbar_sel@2x.png in Resources */, 230 | 4B2A72FA1D5826E1006A1C65 /* me_tabbar_sel@3x.png in Resources */, 231 | 4B2A72EB1D5826E1006A1C65 /* find_tabbar@2x.png in Resources */, 232 | 4B2A72F41D5826E1006A1C65 /* home_tabbar@3x.png in Resources */, 233 | 4B2A72F71D5826E1006A1C65 /* me_tabbar@2x.png in Resources */, 234 | 4B2A72F31D5826E1006A1C65 /* home_tabbar@2x.png in Resources */, 235 | 4B2A72EC1D5826E1006A1C65 /* find_tabbar@3x.png in Resources */, 236 | 4B2A72FD1D5826E1006A1C65 /* msg_tabbar_sel@2x.png in Resources */, 237 | 4B2A72FB1D5826E1006A1C65 /* msg_tabbar@2x.png in Resources */, 238 | 4B2A72EE1D5826E1006A1C65 /* find_tabbar_sel@3x.png in Resources */, 239 | 4B2A72F21D5826E1006A1C65 /* friend_tabbar_sel@3x.png in Resources */, 240 | 4B2A72F11D5826E1006A1C65 /* friend_tabbar_sel@2x.png in Resources */, 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | /* End PBXResourcesBuildPhase section */ 245 | 246 | /* Begin PBXSourcesBuildPhase section */ 247 | 4B2A72B11D5826B1006A1C65 /* Sources */ = { 248 | isa = PBXSourcesBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | 4B2A72E91D5826E1006A1C65 /* MsgVC.swift in Sources */, 252 | 4B7C87A71D6195820099E1FA /* XHTabBar.swift in Sources */, 253 | 4B2A72E81D5826E1006A1C65 /* MeVC.swift in Sources */, 254 | 4B2A72E71D5826E1006A1C65 /* MainVC.swift in Sources */, 255 | 4B2A72E61D5826E1006A1C65 /* FriendVC.swift in Sources */, 256 | 4B2A72B91D5826B1006A1C65 /* AppDelegate.swift in Sources */, 257 | ); 258 | runOnlyForDeploymentPostprocessing = 0; 259 | }; 260 | /* End PBXSourcesBuildPhase section */ 261 | 262 | /* Begin PBXVariantGroup section */ 263 | 4B2A72C11D5826B1006A1C65 /* LaunchScreen.storyboard */ = { 264 | isa = PBXVariantGroup; 265 | children = ( 266 | 4B2A72C21D5826B1006A1C65 /* Base */, 267 | ); 268 | name = LaunchScreen.storyboard; 269 | sourceTree = ""; 270 | }; 271 | /* End PBXVariantGroup section */ 272 | 273 | /* Begin XCBuildConfiguration section */ 274 | 4B2A72C51D5826B1006A1C65 /* Debug */ = { 275 | isa = XCBuildConfiguration; 276 | buildSettings = { 277 | ALWAYS_SEARCH_USER_PATHS = NO; 278 | CLANG_ANALYZER_NONNULL = YES; 279 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 280 | CLANG_CXX_LIBRARY = "libc++"; 281 | CLANG_ENABLE_MODULES = YES; 282 | CLANG_ENABLE_OBJC_ARC = YES; 283 | CLANG_WARN_BOOL_CONVERSION = YES; 284 | CLANG_WARN_CONSTANT_CONVERSION = YES; 285 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 286 | CLANG_WARN_EMPTY_BODY = YES; 287 | CLANG_WARN_ENUM_CONVERSION = YES; 288 | CLANG_WARN_INFINITE_RECURSION = YES; 289 | CLANG_WARN_INT_CONVERSION = YES; 290 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 291 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 292 | CLANG_WARN_UNREACHABLE_CODE = YES; 293 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 294 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 295 | COPY_PHASE_STRIP = NO; 296 | DEBUG_INFORMATION_FORMAT = dwarf; 297 | ENABLE_STRICT_OBJC_MSGSEND = YES; 298 | ENABLE_TESTABILITY = YES; 299 | GCC_C_LANGUAGE_STANDARD = gnu99; 300 | GCC_DYNAMIC_NO_PIC = NO; 301 | GCC_NO_COMMON_BLOCKS = YES; 302 | GCC_OPTIMIZATION_LEVEL = 0; 303 | GCC_PREPROCESSOR_DEFINITIONS = ( 304 | "DEBUG=1", 305 | "$(inherited)", 306 | ); 307 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 308 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 309 | GCC_WARN_UNDECLARED_SELECTOR = YES; 310 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 311 | GCC_WARN_UNUSED_FUNCTION = YES; 312 | GCC_WARN_UNUSED_VARIABLE = YES; 313 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 314 | MTL_ENABLE_DEBUG_INFO = YES; 315 | ONLY_ACTIVE_ARCH = YES; 316 | SDKROOT = iphoneos; 317 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 318 | }; 319 | name = Debug; 320 | }; 321 | 4B2A72C61D5826B1006A1C65 /* Release */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | ALWAYS_SEARCH_USER_PATHS = NO; 325 | CLANG_ANALYZER_NONNULL = YES; 326 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 327 | CLANG_CXX_LIBRARY = "libc++"; 328 | CLANG_ENABLE_MODULES = YES; 329 | CLANG_ENABLE_OBJC_ARC = YES; 330 | CLANG_WARN_BOOL_CONVERSION = YES; 331 | CLANG_WARN_CONSTANT_CONVERSION = YES; 332 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 333 | CLANG_WARN_EMPTY_BODY = YES; 334 | CLANG_WARN_ENUM_CONVERSION = YES; 335 | CLANG_WARN_INFINITE_RECURSION = YES; 336 | CLANG_WARN_INT_CONVERSION = YES; 337 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 338 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 339 | CLANG_WARN_UNREACHABLE_CODE = YES; 340 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 341 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 342 | COPY_PHASE_STRIP = NO; 343 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 344 | ENABLE_NS_ASSERTIONS = NO; 345 | ENABLE_STRICT_OBJC_MSGSEND = YES; 346 | GCC_C_LANGUAGE_STANDARD = gnu99; 347 | GCC_NO_COMMON_BLOCKS = YES; 348 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 349 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 350 | GCC_WARN_UNDECLARED_SELECTOR = YES; 351 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 352 | GCC_WARN_UNUSED_FUNCTION = YES; 353 | GCC_WARN_UNUSED_VARIABLE = YES; 354 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 355 | MTL_ENABLE_DEBUG_INFO = NO; 356 | SDKROOT = iphoneos; 357 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 358 | VALIDATE_PRODUCT = YES; 359 | }; 360 | name = Release; 361 | }; 362 | 4B2A72C81D5826B1006A1C65 /* Debug */ = { 363 | isa = XCBuildConfiguration; 364 | buildSettings = { 365 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 366 | DEVELOPMENT_TEAM = ""; 367 | INFOPLIST_FILE = XHTabBarExampleSwift/Info.plist; 368 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 369 | PRODUCT_BUNDLE_IDENTIFIER = CoderZhuXH.XHTabBarExampleSwift; 370 | PRODUCT_NAME = "$(TARGET_NAME)"; 371 | SWIFT_VERSION = 3.0; 372 | }; 373 | name = Debug; 374 | }; 375 | 4B2A72C91D5826B1006A1C65 /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 379 | DEVELOPMENT_TEAM = ""; 380 | INFOPLIST_FILE = XHTabBarExampleSwift/Info.plist; 381 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 382 | PRODUCT_BUNDLE_IDENTIFIER = CoderZhuXH.XHTabBarExampleSwift; 383 | PRODUCT_NAME = "$(TARGET_NAME)"; 384 | SWIFT_VERSION = 3.0; 385 | }; 386 | name = Release; 387 | }; 388 | /* End XCBuildConfiguration section */ 389 | 390 | /* Begin XCConfigurationList section */ 391 | 4B2A72B01D5826B0006A1C65 /* Build configuration list for PBXProject "XHTabBarExampleSwift" */ = { 392 | isa = XCConfigurationList; 393 | buildConfigurations = ( 394 | 4B2A72C51D5826B1006A1C65 /* Debug */, 395 | 4B2A72C61D5826B1006A1C65 /* Release */, 396 | ); 397 | defaultConfigurationIsVisible = 0; 398 | defaultConfigurationName = Release; 399 | }; 400 | 4B2A72C71D5826B1006A1C65 /* Build configuration list for PBXNativeTarget "XHTabBarExampleSwift" */ = { 401 | isa = XCConfigurationList; 402 | buildConfigurations = ( 403 | 4B2A72C81D5826B1006A1C65 /* Debug */, 404 | 4B2A72C91D5826B1006A1C65 /* Release */, 405 | ); 406 | defaultConfigurationIsVisible = 0; 407 | defaultConfigurationName = Release; 408 | }; 409 | /* End XCConfigurationList section */ 410 | }; 411 | rootObject = 4B2A72AD1D5826B0006A1C65 /* Project object */; 412 | } 413 | -------------------------------------------------------------------------------- /XHTabBarExampleSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /XHTabBarExampleSwift.xcodeproj/project.xcworkspace/xcuserdata/xiaohui.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderZhuXH/XHTabBarSwift/1b003a84eab05d0c65ce55d87b4742498e6c75df/XHTabBarExampleSwift.xcodeproj/project.xcworkspace/xcuserdata/xiaohui.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /XHTabBarExampleSwift.xcodeproj/xcuserdata/xiaohui.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /XHTabBarExampleSwift.xcodeproj/xcuserdata/xiaohui.xcuserdatad/xcschemes/XHTabBarExampleSwift.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /XHTabBarExampleSwift.xcodeproj/xcuserdata/xiaohui.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | XHTabBarExampleSwift.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4B2A72B41D5826B1006A1C65 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /XHTabBarExampleSwift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // XHTabBarExampleSwift 4 | // 5 | // Created by xiaohui on 16/8/8. 6 | // Copyright © 2016年 CoderZhuXH. All rights reserved. 7 | // 代码地址:https://github.com/CoderZhuXH/XHTabBarSwift 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | 19 | window = UIWindow(frame:UIScreen.main.bounds) 20 | window?.backgroundColor = UIColor.white 21 | 22 | 23 | /* 24 | 控制器name数组 25 | */ 26 | let controllerArray = ["MainVC","MsgVC","FriendVC","MeVC"] 27 | /* 28 | title数组 29 | */ 30 | let titleArray = ["首页","消息","朋友","我的"] 31 | /* 32 | 默认图片数组 33 | */ 34 | let imageArray = ["home_tabbar","msg_tabbar","friend_tabbar","me_tabbar"] 35 | /* 36 | 选中图片数组 37 | */ 38 | let selImageArray = ["home_tabbar_sel","msg_tabbar_sel","friend_tabbar_sel","me_tabbar_sel"] 39 | /* 40 | tabbar高度最小值49.0, 传nil或<49.0均按49.0处理 41 | */ 42 | let height = CGFloat(49) 43 | 44 | /* 45 | 创建tabBarController 46 | */ 47 | let tabBarController = XHTabBar(controllerArray:controllerArray,titleArray: titleArray,imageArray: imageArray,selImageArray: selImageArray,height:height) 48 | 49 | /** 50 | * 设为根控制器 51 | */ 52 | window?.rootViewController = tabBarController 53 | 54 | /* 55 | 设置数字角标(可选) 56 | */ 57 | tabBarController.showBadgeMark(100, index: 1) 58 | 59 | /* 60 | 设置小红点(可选) 61 | */ 62 | tabBarController.showPointMarkIndex(2) 63 | 64 | /* 65 | 不显示小红点/数字角标(可选) 66 | */ 67 | //tabBarController.hideMarkIndex(3) 68 | 69 | /* 70 | 手动切换tabBarController 显示到指定控制器(可选) 71 | */ 72 | //tabBarController.showControllerIndex(3) 73 | 74 | 75 | window?.makeKeyAndVisible() 76 | 77 | // Override point for customization after application launch. 78 | return true 79 | } 80 | 81 | func applicationWillResignActive(_ application: UIApplication) { 82 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 83 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 84 | } 85 | 86 | func applicationDidEnterBackground(_ application: UIApplication) { 87 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 88 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 89 | } 90 | 91 | func applicationWillEnterForeground(_ application: UIApplication) { 92 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 93 | } 94 | 95 | func applicationDidBecomeActive(_ application: UIApplication) { 96 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 97 | } 98 | 99 | func applicationWillTerminate(_ application: UIApplication) { 100 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 101 | } 102 | 103 | 104 | } 105 | 106 | -------------------------------------------------------------------------------- /XHTabBarExampleSwift/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /XHTabBarExampleSwift/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /XHTabBarExampleSwift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /XHTabBarSwift.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "XHTabBarSwift" 3 | s.version = "1.1.1" 4 | s.summary = "一行代码创建自定义TabBar,支持小红点,数字角标及自定义高度" 5 | s.homepage = "https://github.com/CoderZhuXH/XHTabBarSwift" 6 | s.license = { :type => "MIT", :file => "LICENSE" } 7 | s.authors = { "Zhu Xiaohui" => "977950862@qq.com"} 8 | s.platform = :ios, "8.0" 9 | s.source = { :git => "https://github.com/CoderZhuXH/XHTabBarSwift.git", :tag => s.version } 10 | s.source_files = "XHTabBarSwift", "*.{swift}" 11 | s.requires_arc = true 12 | end 13 | -------------------------------------------------------------------------------- /XHTabBarSwift/XHTabBar.swift: -------------------------------------------------------------------------------- 1 | // 2 | // XHTabBar.swift 3 | // XHTabBarExampleSwift 4 | // 5 | // Created by xiaohui on 16/8/8. 6 | // Copyright © 2016年 CoderZhuXH. All rights reserved. 7 | // 代码地址:https://github.com/CoderZhuXH/XHTabBarSwift 8 | 9 | import UIKit 10 | 11 | /** 12 | * RGBA颜色 13 | */ 14 | func ColorRGBA(_ r:CGFloat,g:CGFloat,b:CGFloat,a:CGFloat) -> UIColor { 15 | 16 | return UIColor(red:r/255.0,green:g/255.0,blue:b/255.0,alpha:a) 17 | } 18 | /** 19 | * RGB颜色 20 | */ 21 | func ColorRGB(_ r:CGFloat,g:CGFloat,b:CGFloat) -> UIColor { 22 | 23 | return ColorRGBA(r, g: g, b: b, a: 1.0) 24 | } 25 | /** 26 | * 随机色 27 | */ 28 | func ColorRandom() -> UIColor { 29 | 30 | return ColorRGB(CGFloat(arc4random()%255), g: CGFloat(arc4random()%255), b: CGFloat(arc4random()%255)) 31 | } 32 | /** 33 | * 屏幕宽度 34 | */ 35 | private let MWIDTH = UIScreen.main.bounds.size.width 36 | 37 | /** 38 | * 屏幕高度 39 | */ 40 | private let MHEIGHT = UIScreen.main.bounds.size.height 41 | 42 | /** 43 | * tabbar背景色 44 | */ 45 | private let ColorTabBar = UIColor.white 46 | 47 | /** 48 | * title默认颜色 49 | */ 50 | private let ColorTitle = UIColor.gray 51 | 52 | /** 53 | * title选中颜色 54 | */ 55 | private let ColorTitleSel = ColorRGB(41,g: 167,b: 245) 56 | 57 | /** 58 | * title字体大小 59 | */ 60 | private let titleFontSize : CGFloat = 12.0 61 | 62 | /** 63 | * 数字角标直径 64 | */ 65 | private let numMarkD:CGFloat = 20.0 66 | 67 | /** 68 | * 小红点直径 69 | */ 70 | private let pointMarkD:CGFloat = 12.0 71 | 72 | /** 73 | * button 图片与文字上下占比 74 | */ 75 | private let scale:CGFloat = 0.55 76 | 77 | 78 | extension XHTabBar{ 79 | 80 | /** 81 | * 切换显示控制器 82 | * 83 | * - param: index 位置 84 | */ 85 | public func showControllerIndex(_ index: Int) { 86 | 87 | guard index < controllerArray.count else 88 | { 89 | print("error:index="+"\(index)"+"超出范围") 90 | return; 91 | } 92 | self.seleBtn!.isSelected = false 93 | let button = (cusTabbar.viewWithTag(1000+index) as? UIButton)! 94 | button.isSelected = true 95 | self.seleBtn = button 96 | self.selectedIndex = index 97 | } 98 | 99 | /** 100 | * 设置数字角标 101 | * 102 | * - param: num 所要显示数字 103 | * - param: index 位置 104 | */ 105 | public func showBadgeMark(_ badge: Int, index: Int) { 106 | 107 | guard index < controllerArray.count else 108 | { 109 | print("error:index="+"\(index)"+"超出范围") 110 | return; 111 | } 112 | 113 | let numLabel = (cusTabbar.viewWithTag(1020+index) as? UILabel)! 114 | numLabel.isHidden = false 115 | var nFrame = numLabel.frame 116 | if badge <= 0 { 117 | //隐藏角标 118 | self.hideMarkIndex(index) 119 | 120 | } else { 121 | 122 | if badge > 0 && badge <= 9 { 123 | 124 | nFrame.size.width = numMarkD 125 | 126 | } else if badge > 9 && badge <= 19 { 127 | 128 | nFrame.size.width = numMarkD+5 129 | 130 | } else { 131 | 132 | nFrame.size.width = numMarkD+10 133 | 134 | } 135 | nFrame.size.height = numMarkD 136 | numLabel.frame = nFrame 137 | numLabel.layer.cornerRadius = numMarkD/2.0 138 | numLabel.text = "\(badge)" 139 | if badge > 99 { 140 | numLabel.text = "99+" 141 | } 142 | 143 | } 144 | } 145 | 146 | /** 147 | * 设置小红点 148 | * 149 | * - param: index 位置 150 | */ 151 | public func showPointMarkIndex(_ index: Int) { 152 | guard index < controllerArray.count else 153 | { 154 | print("error:index="+"\(index)"+"超出范围") 155 | return; 156 | } 157 | let numLabel = (cusTabbar.viewWithTag(1020+index) as? UILabel)! 158 | numLabel.isHidden = false 159 | var nFrame = numLabel.frame 160 | nFrame.size.height = pointMarkD 161 | nFrame.size.width = pointMarkD 162 | numLabel.frame = nFrame 163 | numLabel.layer.cornerRadius = pointMarkD/2.0 164 | numLabel.text = "" 165 | } 166 | 167 | /** 168 | * 影藏指定位置角标 169 | * 170 | * - param: index 位置 171 | */ 172 | public func hideMarkIndex(_ index: Int) { 173 | guard index < controllerArray.count else 174 | { 175 | print("error:index="+"\(index)"+"超出范围") 176 | return; 177 | } 178 | let numLabel = (cusTabbar.viewWithTag(1020+index) as? UILabel)! 179 | numLabel.isHidden = true 180 | } 181 | 182 | } 183 | //MARK: - TabBarButton 184 | class XHTabBarButton:UIButton { 185 | 186 | override var isHighlighted: Bool{ 187 | 188 | didSet{ 189 | super.isHighlighted = false 190 | } 191 | } 192 | 193 | override init(frame: CGRect) { 194 | 195 | super.init(frame: frame) 196 | 197 | imageView?.contentMode = UIViewContentMode.scaleAspectFit 198 | titleLabel?.textAlignment = NSTextAlignment.center 199 | 200 | } 201 | 202 | required init?(coder aDecoder: NSCoder) { 203 | fatalError("init(coder:) has not been implemented") 204 | } 205 | 206 | 207 | override func imageRect(forContentRect contentRect: CGRect) -> CGRect { 208 | let newX:CGFloat = 0.0 209 | let newY:CGFloat = 5.0 210 | let newWidth:CGFloat = CGFloat(contentRect.size.width) 211 | let newHeight:CGFloat = CGFloat(contentRect.size.height)*scale-newY 212 | return CGRect(x: newX, y: newY, width: newWidth, height: newHeight) 213 | } 214 | 215 | override func titleRect(forContentRect contentRect: CGRect) -> CGRect { 216 | let newX: CGFloat = 0 217 | let newY: CGFloat = contentRect.size.height*scale 218 | let newWidth: CGFloat = contentRect.size.width 219 | let newHeight: CGFloat = contentRect.size.height-contentRect.size.height*scale 220 | return CGRect(x: newX, y: newY, width: newWidth, height: newHeight) 221 | } 222 | 223 | } 224 | 225 | //MARK: - TabBarController 226 | open class XHTabBar:UITabBarController { 227 | 228 | var seleBtn: UIButton? 229 | var tabBarHeight:CGFloat = 49.0 230 | var titleArray = [String]() 231 | var imageArray = [String]() 232 | var selImageArray = [String]() 233 | var controllerArray = [String]() 234 | 235 | 236 | public init(controllerArray: [String], titleArray: [String],imageArray: [String],selImageArray: [String],height: CGFloat?) { 237 | 238 | self.controllerArray = controllerArray 239 | self.titleArray = titleArray 240 | self.imageArray = imageArray 241 | self.selImageArray = selImageArray 242 | 243 | if let tempHeight = height 244 | { 245 | tabBarHeight = tempHeight; 246 | } 247 | if tabBarHeight < 49.0 248 | { 249 | tabBarHeight = 49.0 250 | } 251 | 252 | super.init(nibName: nil, bundle: nil) 253 | } 254 | 255 | override open func viewDidLoad() { 256 | super.viewDidLoad() 257 | 258 | addController() 259 | self.tabBar.addSubview(cusTabbar) 260 | addTabBarButton() 261 | setupTabbarLine() 262 | } 263 | 264 | override open func viewWillLayoutSubviews() { 265 | 266 | super.viewWillLayoutSubviews() 267 | self.removeTabBarButton() 268 | } 269 | 270 | required public init?(coder aDecoder: NSCoder) { 271 | fatalError("init(coder:) has not been implemented") 272 | } 273 | 274 | /** 275 | 添加控制器 276 | */ 277 | fileprivate func addController(){ 278 | 279 | guard controllerArray.count > 0 else 280 | { 281 | print("error:控制器数组为nil") 282 | return 283 | } 284 | 285 | var navArray = [UIViewController]() 286 | //获取命名空间 287 | let ns = Bundle.main.infoDictionary!["CFBundleExecutable"] as! String 288 | 289 | for (index, className) in controllerArray.enumerated() { 290 | 291 | // 将类名转化为类 292 | let cls: AnyClass? = NSClassFromString(ns + "." + className) 293 | 294 | //Swift中如果想通过一个Class来创建一个对象, 必须告诉系统这个Class的确切类型 295 | guard let vcCls = cls as? UIViewController.Type else 296 | { 297 | print("error:cls不能当做UIViewController") 298 | return 299 | } 300 | let vc = vcCls.init() 301 | vc.title = titleArray[index] 302 | let nav = UINavigationController(rootViewController:vc) 303 | navArray.append(nav) 304 | } 305 | 306 | viewControllers = navArray; 307 | } 308 | 309 | /** 310 | * 移除系统创建的UITabBarButton 311 | */ 312 | fileprivate func removeTabBarButton() 313 | { 314 | for view in tabBar.subviews { 315 | if view.isKind(of: NSClassFromString("UITabBarButton")!) { 316 | view.removeFromSuperview() 317 | } 318 | } 319 | 320 | } 321 | 322 | /** 323 | 添加tabbarButton 324 | */ 325 | fileprivate func addTabBarButton() 326 | { 327 | 328 | let num = controllerArray.count 329 | for i in 0..49 tabbar顶部线 373 | */ 374 | fileprivate func setupTabbarLine() 375 | { 376 | guard tabBarHeight > 49 else 377 | { 378 | return; 379 | } 380 | self.tabBar.shadowImage = UIImage.init() 381 | self.tabBar.backgroundImage = UIImage.init() 382 | let line = UILabel(frame: CGRect(x: 0, y: 0,width: MWIDTH, height: 0.5)) 383 | line.backgroundColor = UIColor.lightGray 384 | cusTabbar.addSubview(line) 385 | } 386 | 387 | //MARK: - Action 388 | @objc fileprivate func buttonAction(_ button: UIButton) { 389 | let index: Int = button.tag-1000 390 | self.showControllerIndex(index) 391 | } 392 | 393 | //MARK: - 懒加载 394 | fileprivate lazy var cusTabbar: UIView = { 395 | 396 | let x = CGFloat(0) 397 | let y = 49.0 - self.tabBarHeight 398 | let width = MWIDTH 399 | let height = self.tabBarHeight 400 | 401 | let view = UIView(frame:CGRect(x: x,y: y,width: width,height: height)) 402 | view.backgroundColor = ColorTabBar 403 | 404 | return view 405 | }() 406 | 407 | } 408 | --------------------------------------------------------------------------------