├── .gitignore ├── CCNavTab.podspec ├── CCNavTab.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── bear.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── bear.xcuserdatad │ └── xcschemes │ ├── CCNavTab.xcscheme │ └── xcschememanagement.plist ├── CCNavTab ├── CCNavTab.h ├── CCNavTab │ ├── CCNavigationController.h │ ├── CCNavigationController.m │ ├── CCTabBar.h │ ├── CCTabBar.m │ ├── CCTabController.h │ ├── CCTabController.m │ ├── CCTabItem.h │ ├── CCTabItem.m │ └── Category │ │ ├── UIBarButtonItem+CC.h │ │ └── UIBarButtonItem+CC.m └── Info.plist ├── Demo ├── CCNavTab.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── bear.xcuserdatad │ │ └── xcschemes │ │ ├── CCNavTab.xcscheme │ │ └── xcschememanagement.plist └── CCNavTab │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── background.imageset │ │ ├── Contents.json │ │ └── tabbar_background.png │ └── tab │ │ ├── Contents.json │ │ ├── icon_classTable.imageset │ │ ├── Contents.json │ │ ├── icon_classTable@2x.png │ │ └── icon_classTable@3x.png │ │ ├── icon_classTable_selected.imageset │ │ ├── Contents.json │ │ ├── icon_classTable_selected@2x.png │ │ └── icon_classTable_selected@3x.png │ │ ├── icon_discover.imageset │ │ ├── Contents.json │ │ ├── icon_discover@2x.png │ │ └── icon_discover@3x.png │ │ ├── icon_discover_selected.imageset │ │ ├── Contents.json │ │ ├── icon_discover_selected@2x.png │ │ └── icon_discover_selected@3x.png │ │ ├── icon_me.imageset │ │ ├── Contents.json │ │ ├── icon_me@2x.png │ │ └── icon_me@3x.png │ │ └── icon_me_selected.imageset │ │ ├── Contents.json │ │ ├── icon_me_selected@2x.png │ │ └── icon_me_selected@3x.png │ ├── Base.lproj │ └── LaunchScreen.storyboard │ ├── Classes │ ├── Lib │ │ └── CCNavTab │ │ │ ├── CCNavigationController.h │ │ │ ├── CCNavigationController.m │ │ │ ├── CCTabBar.h │ │ │ ├── CCTabBar.m │ │ │ ├── CCTabController.h │ │ │ ├── CCTabController.m │ │ │ ├── CCTabItem.h │ │ │ ├── CCTabItem.m │ │ │ └── Category │ │ │ ├── UIBarButtonItem+CC.h │ │ │ └── UIBarButtonItem+CC.m │ ├── Main │ │ ├── MainController.h │ │ └── MainController.m │ ├── One │ │ ├── OneController.h │ │ └── OneController.m │ ├── Three │ │ ├── ThreeController.h │ │ └── ThreeController.m │ └── Two │ │ ├── TwoController.h │ │ └── TwoController.m │ ├── Info.plist │ └── main.m ├── LICENSE ├── Lib └── CCNavTab │ ├── CCNavigationController.h │ ├── CCNavigationController.m │ ├── CCTabBar.h │ ├── CCTabBar.m │ ├── CCTabController.h │ ├── CCTabController.m │ ├── CCTabItem.h │ ├── CCTabItem.m │ └── Category │ ├── UIBarButtonItem+CC.h │ └── UIBarButtonItem+CC.m ├── README.md └── demoCapture.gif /.gitignore: -------------------------------------------------------------------------------- 1 | tignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 2 | 3 | ## Build generated 4 | build/ 5 | DerivedData/ 6 | 7 | ## Various settings 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata/ 17 | 18 | ## Other 19 | *.moved-aside 20 | *.xcuserstate 21 | 22 | ## Obj-C/Swift specific 23 | *.hmap 24 | *.ipa 25 | *.dSYM.zip 26 | *.dSYM 27 | 28 | # CocoaPods 29 | # 30 | # We recommend against adding the Pods directory to your .gitignore. However 31 | # you should judge for yourself, the pros and cons are mentioned at: 32 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 33 | # 34 | # Pods/ 35 | 36 | # Carthage 37 | # 38 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 39 | # Carthage/Checkouts 40 | 41 | Carthage/Build 42 | 43 | # fastlane 44 | # 45 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 46 | # screenshots whenever they are needed. 47 | # For more information about the recommended setup visit: 48 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 49 | 50 | fastlane/report.xml 51 | fastlane/screenshots 52 | 53 | #Code Injection 54 | # 55 | # After new code Injection tools there's a generated folder /iOSInjectionProject 56 | # https://github.com/johnno1962/injectionforxcode 57 | 58 | iOSInjectionProject/ 59 | -------------------------------------------------------------------------------- /CCNavTab.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "CCNavTab" 3 | s.version = "1.5.0" 4 | s.summary = "A Easy Way To Construct A Frame for ios." 5 | s.homepage = "https://github.com/xiongcaichang/CCNavTab" 6 | s.license = "LICENSE" 7 | s.author = { "CC" => "15223245@qq.com" } 8 | s.platform = :ios, "6.0" 9 | s.source = { :git => "https://github.com/xiongcaichang/CCNavTab.git", :tag => "1.5.0" } 10 | s.source_files = "CCNavTab", "Lib/CCNavTab/**/*.{h,m}" 11 | s.framework = "UIKit" 12 | end -------------------------------------------------------------------------------- /CCNavTab.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 095FD1951D05CB7E005D9FCC /* CCNavTab.h in Headers */ = {isa = PBXBuildFile; fileRef = 095FD1941D05CB7E005D9FCC /* CCNavTab.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 095FD1A81D05CB9D005D9FCC /* UIBarButtonItem+CC.h in Headers */ = {isa = PBXBuildFile; fileRef = 095FD19E1D05CB9D005D9FCC /* UIBarButtonItem+CC.h */; }; 12 | 095FD1A91D05CB9D005D9FCC /* UIBarButtonItem+CC.m in Sources */ = {isa = PBXBuildFile; fileRef = 095FD19F1D05CB9D005D9FCC /* UIBarButtonItem+CC.m */; }; 13 | 095FD1AA1D05CB9D005D9FCC /* CCNavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 095FD1A01D05CB9D005D9FCC /* CCNavigationController.h */; }; 14 | 095FD1AB1D05CB9D005D9FCC /* CCNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 095FD1A11D05CB9D005D9FCC /* CCNavigationController.m */; }; 15 | 095FD1AC1D05CB9D005D9FCC /* CCTabBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 095FD1A21D05CB9D005D9FCC /* CCTabBar.h */; }; 16 | 095FD1AD1D05CB9D005D9FCC /* CCTabBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 095FD1A31D05CB9D005D9FCC /* CCTabBar.m */; }; 17 | 095FD1AE1D05CB9D005D9FCC /* CCTabController.h in Headers */ = {isa = PBXBuildFile; fileRef = 095FD1A41D05CB9D005D9FCC /* CCTabController.h */; }; 18 | 095FD1AF1D05CB9D005D9FCC /* CCTabController.m in Sources */ = {isa = PBXBuildFile; fileRef = 095FD1A51D05CB9D005D9FCC /* CCTabController.m */; }; 19 | 095FD1B01D05CB9D005D9FCC /* CCTabItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 095FD1A61D05CB9D005D9FCC /* CCTabItem.h */; }; 20 | 095FD1B11D05CB9D005D9FCC /* CCTabItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 095FD1A71D05CB9D005D9FCC /* CCTabItem.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 095FD1911D05CB7E005D9FCC /* CCNavTab.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CCNavTab.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | 095FD1941D05CB7E005D9FCC /* CCNavTab.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCNavTab.h; sourceTree = ""; }; 26 | 095FD1961D05CB7E005D9FCC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | 095FD19E1D05CB9D005D9FCC /* UIBarButtonItem+CC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIBarButtonItem+CC.h"; sourceTree = ""; }; 28 | 095FD19F1D05CB9D005D9FCC /* UIBarButtonItem+CC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIBarButtonItem+CC.m"; sourceTree = ""; }; 29 | 095FD1A01D05CB9D005D9FCC /* CCNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNavigationController.h; sourceTree = ""; }; 30 | 095FD1A11D05CB9D005D9FCC /* CCNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCNavigationController.m; sourceTree = ""; }; 31 | 095FD1A21D05CB9D005D9FCC /* CCTabBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTabBar.h; sourceTree = ""; }; 32 | 095FD1A31D05CB9D005D9FCC /* CCTabBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCTabBar.m; sourceTree = ""; }; 33 | 095FD1A41D05CB9D005D9FCC /* CCTabController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTabController.h; sourceTree = ""; }; 34 | 095FD1A51D05CB9D005D9FCC /* CCTabController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCTabController.m; sourceTree = ""; }; 35 | 095FD1A61D05CB9D005D9FCC /* CCTabItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTabItem.h; sourceTree = ""; }; 36 | 095FD1A71D05CB9D005D9FCC /* CCTabItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCTabItem.m; sourceTree = ""; }; 37 | /* End PBXFileReference section */ 38 | 39 | /* Begin PBXFrameworksBuildPhase section */ 40 | 095FD18D1D05CB7E005D9FCC /* Frameworks */ = { 41 | isa = PBXFrameworksBuildPhase; 42 | buildActionMask = 2147483647; 43 | files = ( 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | /* End PBXFrameworksBuildPhase section */ 48 | 49 | /* Begin PBXGroup section */ 50 | 095FD1871D05CB7E005D9FCC = { 51 | isa = PBXGroup; 52 | children = ( 53 | 095FD1931D05CB7E005D9FCC /* CCNavTab */, 54 | 095FD1921D05CB7E005D9FCC /* Products */, 55 | ); 56 | sourceTree = ""; 57 | }; 58 | 095FD1921D05CB7E005D9FCC /* Products */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 095FD1911D05CB7E005D9FCC /* CCNavTab.framework */, 62 | ); 63 | name = Products; 64 | sourceTree = ""; 65 | }; 66 | 095FD1931D05CB7E005D9FCC /* CCNavTab */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 095FD1941D05CB7E005D9FCC /* CCNavTab.h */, 70 | 095FD19C1D05CB9D005D9FCC /* CCNavTab */, 71 | 095FD1961D05CB7E005D9FCC /* Info.plist */, 72 | ); 73 | path = CCNavTab; 74 | sourceTree = ""; 75 | }; 76 | 095FD19C1D05CB9D005D9FCC /* CCNavTab */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 095FD19D1D05CB9D005D9FCC /* Category */, 80 | 095FD1A01D05CB9D005D9FCC /* CCNavigationController.h */, 81 | 095FD1A11D05CB9D005D9FCC /* CCNavigationController.m */, 82 | 095FD1A21D05CB9D005D9FCC /* CCTabBar.h */, 83 | 095FD1A31D05CB9D005D9FCC /* CCTabBar.m */, 84 | 095FD1A41D05CB9D005D9FCC /* CCTabController.h */, 85 | 095FD1A51D05CB9D005D9FCC /* CCTabController.m */, 86 | 095FD1A61D05CB9D005D9FCC /* CCTabItem.h */, 87 | 095FD1A71D05CB9D005D9FCC /* CCTabItem.m */, 88 | ); 89 | path = CCNavTab; 90 | sourceTree = ""; 91 | }; 92 | 095FD19D1D05CB9D005D9FCC /* Category */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 095FD19E1D05CB9D005D9FCC /* UIBarButtonItem+CC.h */, 96 | 095FD19F1D05CB9D005D9FCC /* UIBarButtonItem+CC.m */, 97 | ); 98 | path = Category; 99 | sourceTree = ""; 100 | }; 101 | /* End PBXGroup section */ 102 | 103 | /* Begin PBXHeadersBuildPhase section */ 104 | 095FD18E1D05CB7E005D9FCC /* Headers */ = { 105 | isa = PBXHeadersBuildPhase; 106 | buildActionMask = 2147483647; 107 | files = ( 108 | 095FD1A81D05CB9D005D9FCC /* UIBarButtonItem+CC.h in Headers */, 109 | 095FD1AE1D05CB9D005D9FCC /* CCTabController.h in Headers */, 110 | 095FD1AA1D05CB9D005D9FCC /* CCNavigationController.h in Headers */, 111 | 095FD1AC1D05CB9D005D9FCC /* CCTabBar.h in Headers */, 112 | 095FD1951D05CB7E005D9FCC /* CCNavTab.h in Headers */, 113 | 095FD1B01D05CB9D005D9FCC /* CCTabItem.h in Headers */, 114 | ); 115 | runOnlyForDeploymentPostprocessing = 0; 116 | }; 117 | /* End PBXHeadersBuildPhase section */ 118 | 119 | /* Begin PBXNativeTarget section */ 120 | 095FD1901D05CB7E005D9FCC /* CCNavTab */ = { 121 | isa = PBXNativeTarget; 122 | buildConfigurationList = 095FD1991D05CB7E005D9FCC /* Build configuration list for PBXNativeTarget "CCNavTab" */; 123 | buildPhases = ( 124 | 095FD18C1D05CB7E005D9FCC /* Sources */, 125 | 095FD18D1D05CB7E005D9FCC /* Frameworks */, 126 | 095FD18E1D05CB7E005D9FCC /* Headers */, 127 | 095FD18F1D05CB7E005D9FCC /* Resources */, 128 | ); 129 | buildRules = ( 130 | ); 131 | dependencies = ( 132 | ); 133 | name = CCNavTab; 134 | productName = CCNavTab; 135 | productReference = 095FD1911D05CB7E005D9FCC /* CCNavTab.framework */; 136 | productType = "com.apple.product-type.framework"; 137 | }; 138 | /* End PBXNativeTarget section */ 139 | 140 | /* Begin PBXProject section */ 141 | 095FD1881D05CB7E005D9FCC /* Project object */ = { 142 | isa = PBXProject; 143 | attributes = { 144 | LastUpgradeCheck = 0730; 145 | ORGANIZATIONNAME = bear; 146 | TargetAttributes = { 147 | 095FD1901D05CB7E005D9FCC = { 148 | CreatedOnToolsVersion = 7.3.1; 149 | }; 150 | }; 151 | }; 152 | buildConfigurationList = 095FD18B1D05CB7E005D9FCC /* Build configuration list for PBXProject "CCNavTab" */; 153 | compatibilityVersion = "Xcode 3.2"; 154 | developmentRegion = English; 155 | hasScannedForEncodings = 0; 156 | knownRegions = ( 157 | en, 158 | ); 159 | mainGroup = 095FD1871D05CB7E005D9FCC; 160 | productRefGroup = 095FD1921D05CB7E005D9FCC /* Products */; 161 | projectDirPath = ""; 162 | projectRoot = ""; 163 | targets = ( 164 | 095FD1901D05CB7E005D9FCC /* CCNavTab */, 165 | ); 166 | }; 167 | /* End PBXProject section */ 168 | 169 | /* Begin PBXResourcesBuildPhase section */ 170 | 095FD18F1D05CB7E005D9FCC /* Resources */ = { 171 | isa = PBXResourcesBuildPhase; 172 | buildActionMask = 2147483647; 173 | files = ( 174 | ); 175 | runOnlyForDeploymentPostprocessing = 0; 176 | }; 177 | /* End PBXResourcesBuildPhase section */ 178 | 179 | /* Begin PBXSourcesBuildPhase section */ 180 | 095FD18C1D05CB7E005D9FCC /* Sources */ = { 181 | isa = PBXSourcesBuildPhase; 182 | buildActionMask = 2147483647; 183 | files = ( 184 | 095FD1B11D05CB9D005D9FCC /* CCTabItem.m in Sources */, 185 | 095FD1A91D05CB9D005D9FCC /* UIBarButtonItem+CC.m in Sources */, 186 | 095FD1AF1D05CB9D005D9FCC /* CCTabController.m in Sources */, 187 | 095FD1AB1D05CB9D005D9FCC /* CCNavigationController.m in Sources */, 188 | 095FD1AD1D05CB9D005D9FCC /* CCTabBar.m in Sources */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | /* End PBXSourcesBuildPhase section */ 193 | 194 | /* Begin XCBuildConfiguration section */ 195 | 095FD1971D05CB7E005D9FCC /* Debug */ = { 196 | isa = XCBuildConfiguration; 197 | buildSettings = { 198 | ALWAYS_SEARCH_USER_PATHS = NO; 199 | CLANG_ANALYZER_NONNULL = YES; 200 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 201 | CLANG_CXX_LIBRARY = "libc++"; 202 | CLANG_ENABLE_MODULES = YES; 203 | CLANG_ENABLE_OBJC_ARC = YES; 204 | CLANG_WARN_BOOL_CONVERSION = YES; 205 | CLANG_WARN_CONSTANT_CONVERSION = YES; 206 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 207 | CLANG_WARN_EMPTY_BODY = YES; 208 | CLANG_WARN_ENUM_CONVERSION = YES; 209 | CLANG_WARN_INT_CONVERSION = YES; 210 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 211 | CLANG_WARN_UNREACHABLE_CODE = YES; 212 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 213 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 214 | COPY_PHASE_STRIP = NO; 215 | CURRENT_PROJECT_VERSION = 1; 216 | DEBUG_INFORMATION_FORMAT = dwarf; 217 | ENABLE_STRICT_OBJC_MSGSEND = YES; 218 | ENABLE_TESTABILITY = YES; 219 | GCC_C_LANGUAGE_STANDARD = gnu99; 220 | GCC_DYNAMIC_NO_PIC = NO; 221 | GCC_NO_COMMON_BLOCKS = YES; 222 | GCC_OPTIMIZATION_LEVEL = 0; 223 | GCC_PREPROCESSOR_DEFINITIONS = ( 224 | "DEBUG=1", 225 | "$(inherited)", 226 | ); 227 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 228 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 229 | GCC_WARN_UNDECLARED_SELECTOR = YES; 230 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 231 | GCC_WARN_UNUSED_FUNCTION = YES; 232 | GCC_WARN_UNUSED_VARIABLE = YES; 233 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 234 | MACH_O_TYPE = mh_dylib; 235 | MTL_ENABLE_DEBUG_INFO = YES; 236 | ONLY_ACTIVE_ARCH = YES; 237 | SDKROOT = iphoneos; 238 | TARGETED_DEVICE_FAMILY = "1,2"; 239 | VERSIONING_SYSTEM = "apple-generic"; 240 | VERSION_INFO_PREFIX = ""; 241 | }; 242 | name = Debug; 243 | }; 244 | 095FD1981D05CB7E005D9FCC /* Release */ = { 245 | isa = XCBuildConfiguration; 246 | buildSettings = { 247 | ALWAYS_SEARCH_USER_PATHS = NO; 248 | CLANG_ANALYZER_NONNULL = YES; 249 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 250 | CLANG_CXX_LIBRARY = "libc++"; 251 | CLANG_ENABLE_MODULES = YES; 252 | CLANG_ENABLE_OBJC_ARC = YES; 253 | CLANG_WARN_BOOL_CONVERSION = YES; 254 | CLANG_WARN_CONSTANT_CONVERSION = YES; 255 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 256 | CLANG_WARN_EMPTY_BODY = YES; 257 | CLANG_WARN_ENUM_CONVERSION = YES; 258 | CLANG_WARN_INT_CONVERSION = YES; 259 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 260 | CLANG_WARN_UNREACHABLE_CODE = YES; 261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 262 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 263 | COPY_PHASE_STRIP = NO; 264 | CURRENT_PROJECT_VERSION = 1; 265 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 266 | ENABLE_NS_ASSERTIONS = NO; 267 | ENABLE_STRICT_OBJC_MSGSEND = YES; 268 | GCC_C_LANGUAGE_STANDARD = gnu99; 269 | GCC_NO_COMMON_BLOCKS = YES; 270 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 271 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 272 | GCC_WARN_UNDECLARED_SELECTOR = YES; 273 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 274 | GCC_WARN_UNUSED_FUNCTION = YES; 275 | GCC_WARN_UNUSED_VARIABLE = YES; 276 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 277 | MACH_O_TYPE = mh_dylib; 278 | MTL_ENABLE_DEBUG_INFO = NO; 279 | SDKROOT = iphoneos; 280 | TARGETED_DEVICE_FAMILY = "1,2"; 281 | VALIDATE_PRODUCT = YES; 282 | VERSIONING_SYSTEM = "apple-generic"; 283 | VERSION_INFO_PREFIX = ""; 284 | }; 285 | name = Release; 286 | }; 287 | 095FD19A1D05CB7E005D9FCC /* Debug */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | DEFINES_MODULE = YES; 291 | DYLIB_COMPATIBILITY_VERSION = 1; 292 | DYLIB_CURRENT_VERSION = 1; 293 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 294 | INFOPLIST_FILE = CCNavTab/Info.plist; 295 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 296 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 297 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 298 | PRODUCT_BUNDLE_IDENTIFIER = com.xiongcaichang.CCNavTab; 299 | PRODUCT_NAME = "$(TARGET_NAME)"; 300 | SKIP_INSTALL = YES; 301 | }; 302 | name = Debug; 303 | }; 304 | 095FD19B1D05CB7E005D9FCC /* Release */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | DEFINES_MODULE = YES; 308 | DYLIB_COMPATIBILITY_VERSION = 1; 309 | DYLIB_CURRENT_VERSION = 1; 310 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 311 | INFOPLIST_FILE = CCNavTab/Info.plist; 312 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 313 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 314 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 315 | PRODUCT_BUNDLE_IDENTIFIER = com.xiongcaichang.CCNavTab; 316 | PRODUCT_NAME = "$(TARGET_NAME)"; 317 | SKIP_INSTALL = YES; 318 | }; 319 | name = Release; 320 | }; 321 | /* End XCBuildConfiguration section */ 322 | 323 | /* Begin XCConfigurationList section */ 324 | 095FD18B1D05CB7E005D9FCC /* Build configuration list for PBXProject "CCNavTab" */ = { 325 | isa = XCConfigurationList; 326 | buildConfigurations = ( 327 | 095FD1971D05CB7E005D9FCC /* Debug */, 328 | 095FD1981D05CB7E005D9FCC /* Release */, 329 | ); 330 | defaultConfigurationIsVisible = 0; 331 | defaultConfigurationName = Release; 332 | }; 333 | 095FD1991D05CB7E005D9FCC /* Build configuration list for PBXNativeTarget "CCNavTab" */ = { 334 | isa = XCConfigurationList; 335 | buildConfigurations = ( 336 | 095FD19A1D05CB7E005D9FCC /* Debug */, 337 | 095FD19B1D05CB7E005D9FCC /* Release */, 338 | ); 339 | defaultConfigurationIsVisible = 0; 340 | defaultConfigurationName = Release; 341 | }; 342 | /* End XCConfigurationList section */ 343 | }; 344 | rootObject = 095FD1881D05CB7E005D9FCC /* Project object */; 345 | } 346 | -------------------------------------------------------------------------------- /CCNavTab.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CCNavTab.xcodeproj/project.xcworkspace/xcuserdata/bear.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/CCNavTab.xcodeproj/project.xcworkspace/xcuserdata/bear.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /CCNavTab.xcodeproj/xcuserdata/bear.xcuserdatad/xcschemes/CCNavTab.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /CCNavTab.xcodeproj/xcuserdata/bear.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CCNavTab.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 095FD1901D05CB7E005D9FCC 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /CCNavTab/CCNavTab.h: -------------------------------------------------------------------------------- 1 | // 2 | // CCNavTab.h 3 | // CCNavTab 4 | // 5 | // Created by bear on 16/6/6. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for CCNavTab. 12 | FOUNDATION_EXPORT double CCNavTabVersionNumber; 13 | 14 | //! Project version string for CCNavTab. 15 | FOUNDATION_EXPORT const unsigned char CCNavTabVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /CCNavTab/CCNavTab/CCNavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CCNavigationController.h 3 | // CCNavTab 4 | // 5 | // Created by bear on 16/3/24. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CCNavigationController : UINavigationController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /CCNavTab/CCNavTab/CCNavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CCNavigationController.m 3 | // CCNavTab 4 | // 5 | // Created by bear on 16/3/24. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "CCNavigationController.h" 10 | 11 | 12 | #define CCTabBarNotifacationIsHiden @"CCTabBarHiden" 13 | 14 | @interface CCNavigationController () 15 | 16 | @end 17 | 18 | @implementation CCNavigationController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | 23 | 24 | 25 | self.navigationBar.shadowImage=[[UIImage alloc]init]; 26 | 27 | 28 | } 29 | 30 | 31 | 32 | 33 | 34 | - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated 35 | { 36 | 37 | // self - 导航控制器 38 | if (self.viewControllers.count) { // 不是根控制器 39 | 40 | viewController.hidesBottomBarWhenPushed = YES; 41 | } 42 | 43 | 44 | UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; 45 | self.topViewController.navigationItem.backBarButtonItem = backItem; 46 | 47 | 48 | // 调用系统默认做法,因为只有系统才知道怎么做push 49 | [super pushViewController:viewController animated:animated]; 50 | } 51 | 52 | 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /CCNavTab/CCNavTab/CCTabBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+XCC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CCTabItem.h" 11 | 12 | #define kTabBarHeight 49 13 | 14 | @class CCTabBar; 15 | 16 | 17 | 18 | @protocol CCTabBarDelegate 19 | 20 | @optional 21 | -(void)tabbar:(CCTabBar *)tabbar to:(NSInteger)to; 22 | 23 | @end 24 | 25 | 26 | 27 | 28 | @interface CCTabBar : UIView 29 | 30 | @property (nonatomic, weak) CCTabItem *selectedItem; 31 | 32 | //添加tab按钮的方法 33 | -(void)addItemWithIcon:(NSString *)icon selectedIcon:(NSString *)icon_selected title:(NSString *)title; 34 | 35 | @property (nonatomic,weak) id delegate; 36 | 37 | @end 38 | 39 | -------------------------------------------------------------------------------- /CCNavTab/CCNavTab/CCTabBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+XCC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "CCTabBar.h" 10 | #import "CCTabItem.h" 11 | 12 | @implementation CCTabBar 13 | 14 | 15 | - (void)addItemWithIcon:(NSString *)icon selectedIcon:(NSString *)selected title:(NSString *)title 16 | { 17 | // 1.创建item 18 | CCTabItem *item = [[CCTabItem alloc] init]; 19 | 20 | 21 | // 文字 22 | [item setTitle:title forState:UIControlStateNormal]; 23 | item.titleLabel.textColor=[UIColor lightGrayColor]; 24 | 25 | // 图标 26 | [item setImage:[UIImage imageNamed:icon] forState:UIControlStateNormal]; 27 | [item setImage:[UIImage imageNamed:selected] forState:UIControlStateSelected]; 28 | 29 | // 监听item的点击 30 | [item addTarget:self action:@selector(itemClick:) forControlEvents:UIControlEventTouchDown]; 31 | 32 | // 2.添加item 33 | [self addSubview:item]; 34 | NSInteger count = self.subviews.count; 35 | 36 | // 默认选中第一个item 37 | if (count == 1) { 38 | [self itemClick:item]; 39 | } 40 | 41 | // 3.调整所有item的frame 42 | CGFloat height = self.frame.size.height; // 高度 43 | CGFloat width = self.frame.size.width / count; // 宽度 44 | for (int i = 0; i 10 | #import "CCTabBar.h" 11 | 12 | #define ACTION_NAME @"action_name" 13 | 14 | #define VIEWCONTROLLER @"VC" 15 | 16 | #define NORMAL_ICON @"ICONOR" 17 | 18 | #define SELECTED_ICON @"ICONSE" 19 | 20 | #define TITLE @"TITLE" 21 | 22 | 23 | @interface CCTabController :UITabBarController{ 24 | @public 25 | 26 | CCTabBar *_tabBar; 27 | } 28 | 29 | 30 | 31 | //子控制器信息数组 32 | @property (nonatomic, strong) NSArray *childControllerAndIconArr; 33 | 34 | 35 | /** 36 | 配置导航栏的颜色/图片 37 | 注意:当背景颜色设置时图片不生效 navigationBarBackgroundColor navigationBarBackgroundImage一般二选其一 默认为系统白色 38 | */ 39 | @property (nonatomic, strong) UIColor *navigationBarBackgroundColor; 40 | 41 | @property (nonatomic, strong) UIImage *navigationBarBackgroundImage; 42 | 43 | /** 44 | 可选配置 45 | 导航栏文字颜色 Title 和 BarButtonItem 默认为黑色 46 | */ 47 | @property (nonatomic, strong) UIColor *navigationBarTintColor; 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /CCNavTab/CCNavTab/CCTabController.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | #import "CCTabController.h" 9 | #import "CCNavigationController.h" 10 | #import "CCTabItem.h" 11 | 12 | 13 | @interface CCTabController () 14 | 15 | 16 | 17 | 18 | @end 19 | 20 | @implementation CCTabController 21 | 22 | 23 | - (void)viewDidLoad 24 | { 25 | [super viewDidLoad]; 26 | 27 | // 初始化TabBar 28 | [self initTabBar]; 29 | 30 | } 31 | 32 | 33 | - (void)viewWillAppear:(BOOL)animated 34 | { 35 | // 调用系统默认的做法:添加UITabBarButton 36 | [super viewWillAppear:animated]; 37 | 38 | // 删除self.tabBar中的子控件除了自定义tabBar 39 | for (UIView *childView in self.tabBar.subviews) { 40 | if (![childView isKindOfClass:[CCTabBar class]] && ![childView isKindOfClass:[UIImageView class]]) { // 不是自己的tabBar 41 | 42 | [childView removeFromSuperview]; 43 | } 44 | 45 | } 46 | 47 | } 48 | 49 | 50 | 51 | #pragma mark 初始化TabBar 52 | - (void)initTabBar 53 | { 54 | 55 | CCTabBar *tabBar = [[CCTabBar alloc] initWithFrame:self.tabBar.bounds]; 56 | 57 | tabBar.delegate=self; 58 | 59 | [self.tabBar addSubview:tabBar]; 60 | 61 | _tabBar=tabBar; 62 | 63 | } 64 | 65 | 66 | 67 | 68 | #pragma mark tabBar的代理方法 69 | - (void)tabbar:(CCTabBar *)tabbar to:(NSInteger)to{ 70 | 71 | if (to < 0 || to >= self.childViewControllers.count||self.selectedIndex==to) return; 72 | 73 | UIViewController *newVc = self.childViewControllers[to]; 74 | 75 | CGFloat width = self.view.frame.size.width; 76 | 77 | CGFloat height=height = self.view.frame.size.height; 78 | 79 | newVc.view.frame = CGRectMake(0,0, width, height); 80 | 81 | self.selectedIndex=to; 82 | 83 | [self.view bringSubviewToFront:_tabBar]; 84 | 85 | } 86 | 87 | 88 | 89 | 90 | 91 | -(void)setChildControllerAndIconArr:(NSArray *)childControllerAndIconArr{ 92 | 93 | _childControllerAndIconArr=childControllerAndIconArr; 94 | 95 | //遍历配置字典 96 | for (NSInteger i = 0; i < childControllerAndIconArr.count; i++) { 97 | 98 | //取出字典 99 | NSDictionary *dict=childControllerAndIconArr[i]; 100 | 101 | 102 | 103 | UIViewController *vc = [dict objectForKey:VIEWCONTROLLER]; 104 | 105 | 106 | [vc addObserver:self forKeyPath:@"tabBarItem.badgeValue" options:NSKeyValueObservingOptionNew context:NULL]; 107 | 108 | 109 | CCNavigationController *nav=[[CCNavigationController alloc]initWithRootViewController:vc]; 110 | 111 | [vc setTitle:[dict objectForKey:TITLE]]; 112 | 113 | [self addChildViewController:nav]; 114 | 115 | 116 | if (self.navigationBarBackgroundColor == nil) { 117 | 118 | [nav.navigationBar setBackgroundImage:self.navigationBarBackgroundImage forBarMetrics:UIBarMetricsDefault]; 119 | 120 | }else{ 121 | 122 | [nav.navigationBar setBarTintColor:self.navigationBarBackgroundColor]; 123 | 124 | } 125 | 126 | 127 | [nav.navigationBar setTintColor:self.navigationBarTintColor]; 128 | 129 | [nav.navigationItem.backBarButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName:self.navigationBarTintColor} forState:UIControlStateNormal]; 130 | 131 | nav.navigationBar.titleTextAttributes=@{NSForegroundColorAttributeName:self.navigationBarTintColor}; 132 | 133 | 134 | 135 | 136 | [_tabBar addItemWithIcon:[dict objectForKey:NORMAL_ICON] selectedIcon:[dict objectForKey:SELECTED_ICON] title:[dict objectForKey:TITLE]]; 137 | 138 | } 139 | } 140 | 141 | 142 | 143 | 144 | -(UIColor *)navigationBarTintColor{ 145 | if (!_navigationBarTintColor) { 146 | _navigationBarTintColor = [UIColor blackColor]; 147 | } 148 | 149 | return _navigationBarTintColor; 150 | } 151 | 152 | 153 | -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ 154 | if ([keyPath isEqualToString:@"tabBarItem.badgeValue"]) { 155 | 156 | //遍历配置字典 157 | for (NSInteger i = 0; i < self.childControllerAndIconArr.count; i++) { 158 | 159 | //取出字典 160 | NSDictionary *dict=self.childControllerAndIconArr[i]; 161 | 162 | UIViewController *vc = [dict objectForKey:VIEWCONTROLLER]; 163 | 164 | if ([vc isEqual:object]) { 165 | 166 | for (CCTabItem *item in _tabBar.subviews) { 167 | if (item.tag==i) { 168 | if ([change[@"new"] isEqualToString:@"0"]) { 169 | item.bageView.hidden=YES; 170 | }else{ 171 | item.bageView.hidden=NO; 172 | item.bageView.text=change[@"new"]; 173 | } 174 | 175 | } 176 | } 177 | } 178 | 179 | 180 | } 181 | } 182 | 183 | } 184 | 185 | 186 | -(void)dealloc{ 187 | for (NSInteger i = 0; i < self.childControllerAndIconArr.count; i++) { 188 | 189 | NSDictionary *dict=self.childControllerAndIconArr[i]; 190 | 191 | UIViewController *vc = [dict objectForKey:VIEWCONTROLLER]; 192 | [vc removeObserver:self forKeyPath:@"tabBarItem.badgeValue"]; 193 | } 194 | 195 | } 196 | 197 | @end 198 | 199 | 200 | -------------------------------------------------------------------------------- /CCNavTab/CCNavTab/CCTabItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CCTabItem : UIButton 12 | 13 | @property (nonatomic, weak) UILabel *bageView; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /CCNavTab/CCNavTab/CCTabItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "CCTabItem.h" 10 | 11 | #define kDockItemSelectedBG @"tabbar_slider.png" 12 | 13 | // 文字的高度比例 14 | #define kTitleRatio 0.3 15 | 16 | @interface CCTabItem() 17 | 18 | 19 | 20 | 21 | @end 22 | 23 | 24 | @implementation CCTabItem 25 | - (id)initWithFrame:(CGRect)frame 26 | { 27 | self = [super initWithFrame:frame]; 28 | if (self) { 29 | // 1.文字居中 30 | self.titleLabel.textAlignment = NSTextAlignmentCenter; 31 | 32 | // 2.文字大小 33 | CGFloat fontSize=([UIScreen mainScreen].bounds.size.width/414.0)*12; 34 | self.titleLabel.font = [UIFont systemFontOfSize:fontSize]; 35 | [self setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; 36 | 37 | // 3.图片的内容模式 38 | self.imageView.contentMode = UIViewContentModeScaleToFill; 39 | 40 | 41 | //4.添加 bageView 42 | UILabel *label=[[UILabel alloc]init]; 43 | label.layer.cornerRadius=10; 44 | label.font=[UIFont systemFontOfSize:10]; 45 | label.layer.masksToBounds=YES; 46 | label.textAlignment=NSTextAlignmentCenter; 47 | label.backgroundColor=[UIColor redColor]; 48 | label.hidden=YES; 49 | 50 | label.textColor=[UIColor whiteColor]; 51 | [self addSubview:label]; 52 | self.bageView=label; 53 | 54 | 55 | } 56 | return self; 57 | } 58 | 59 | 60 | 61 | 62 | 63 | 64 | #pragma mark 覆盖父类在highlighted时的所有操作 65 | - (void)setHighlighted:(BOOL)highlighted { 66 | [super setHighlighted:highlighted]; 67 | } 68 | 69 | #pragma mark 调整内部ImageView的frame 70 | - (CGRect)imageRectForContentRect:(CGRect)contentRect 71 | { 72 | 73 | CGFloat imageX = (contentRect.size.width-27)*0.5; 74 | CGFloat imageY = 3; 75 | CGFloat imageWidth = 27; 76 | CGFloat imageHeight = 27; 77 | 78 | self.bageView.frame=CGRectMake(imageX+imageWidth+3, 5, 20, 20); 79 | return CGRectMake(imageX, imageY, imageWidth, imageHeight); 80 | } 81 | 82 | #pragma mark 调整内部UILabel的frame 83 | - (CGRect)titleRectForContentRect:(CGRect)contentRect 84 | { 85 | CGFloat titleX = 0; 86 | 87 | CGFloat titleHeight = contentRect.size.height * kTitleRatio; 88 | CGFloat titleY = contentRect.size.height - titleHeight - 3; 89 | CGFloat titleWidth = contentRect.size.width; 90 | return CGRectMake(titleX, titleY, titleWidth, titleHeight); 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /CCNavTab/CCNavTab/Category/UIBarButtonItem+CC.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIBarButtonItem (CC) 12 | /** 13 | * 快速创建item 14 | */ 15 | + (UIBarButtonItem *)itemWithImage:(UIImage *)image highImage:(UIImage *)highImage target:(id)target action:(SEL)action; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /CCNavTab/CCNavTab/Category/UIBarButtonItem+CC.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "UIBarButtonItem+CC.h" 10 | 11 | @implementation UIBarButtonItem (CC) 12 | 13 | + (UIBarButtonItem *)itemWithImage:(UIImage *)image highImage:(UIImage *)highImage target:(id)target action:(SEL)action 14 | { 15 | UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 16 | [button setBackgroundImage:image forState:UIControlStateNormal]; 17 | [button setBackgroundImage:highImage forState:UIControlStateHighlighted]; 18 | [button setFrame:CGRectMake(0, 0, 44, 44)]; 19 | [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside]; 20 | return [[UIBarButtonItem alloc] initWithCustomView:button]; 21 | 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /CCNavTab/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Demo/CCNavTab.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 090A81F11CC31C2F002F6EE2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 090A81F01CC31C2F002F6EE2 /* main.m */; }; 11 | 090A81FC1CC31C2F002F6EE2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 090A81FB1CC31C2F002F6EE2 /* Assets.xcassets */; }; 12 | 095FD1791D05C266005D9FCC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 095FD1781D05C266005D9FCC /* AppDelegate.m */; }; 13 | 095FD1BE1D05DED8005D9FCC /* MainController.m in Sources */ = {isa = PBXBuildFile; fileRef = 095FD1B41D05DED8005D9FCC /* MainController.m */; }; 14 | 095FD1BF1D05DED8005D9FCC /* OneController.m in Sources */ = {isa = PBXBuildFile; fileRef = 095FD1B71D05DED8005D9FCC /* OneController.m */; }; 15 | 095FD1C01D05DED8005D9FCC /* ThreeController.m in Sources */ = {isa = PBXBuildFile; fileRef = 095FD1BA1D05DED8005D9FCC /* ThreeController.m */; }; 16 | 095FD1C11D05DED8005D9FCC /* TwoController.m in Sources */ = {isa = PBXBuildFile; fileRef = 095FD1BD1D05DED8005D9FCC /* TwoController.m */; }; 17 | 097BDB631D13B2300098EEE8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 097BDB611D13B2300098EEE8 /* LaunchScreen.storyboard */; }; 18 | 09FAEE1E1CF571AA00D8DB71 /* UIBarButtonItem+CC.m in Sources */ = {isa = PBXBuildFile; fileRef = 09FAEE151CF571AA00D8DB71 /* UIBarButtonItem+CC.m */; }; 19 | 09FAEE1F1CF571AA00D8DB71 /* CCNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 09FAEE171CF571AA00D8DB71 /* CCNavigationController.m */; }; 20 | 09FAEE201CF571AA00D8DB71 /* CCTabBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 09FAEE191CF571AA00D8DB71 /* CCTabBar.m */; }; 21 | 09FAEE211CF571AA00D8DB71 /* CCTabController.m in Sources */ = {isa = PBXBuildFile; fileRef = 09FAEE1B1CF571AA00D8DB71 /* CCTabController.m */; }; 22 | 09FAEE221CF571AA00D8DB71 /* CCTabItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 09FAEE1D1CF571AA00D8DB71 /* CCTabItem.m */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXFileReference section */ 26 | 090A81EC1CC31C2F002F6EE2 /* CCNavTab.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CCNavTab.app; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | 090A81F01CC31C2F002F6EE2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 28 | 090A81FB1CC31C2F002F6EE2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 29 | 090A82001CC31C2F002F6EE2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | 095FD1771D05C266005D9FCC /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 31 | 095FD1781D05C266005D9FCC /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 32 | 095FD1B31D05DED8005D9FCC /* MainController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainController.h; sourceTree = ""; }; 33 | 095FD1B41D05DED8005D9FCC /* MainController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainController.m; sourceTree = ""; }; 34 | 095FD1B61D05DED8005D9FCC /* OneController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OneController.h; sourceTree = ""; }; 35 | 095FD1B71D05DED8005D9FCC /* OneController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OneController.m; sourceTree = ""; }; 36 | 095FD1B91D05DED8005D9FCC /* ThreeController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreeController.h; sourceTree = ""; }; 37 | 095FD1BA1D05DED8005D9FCC /* ThreeController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ThreeController.m; sourceTree = ""; }; 38 | 095FD1BC1D05DED8005D9FCC /* TwoController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TwoController.h; sourceTree = ""; }; 39 | 095FD1BD1D05DED8005D9FCC /* TwoController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TwoController.m; sourceTree = ""; }; 40 | 097BDB621D13B2300098EEE8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 41 | 09FAEE141CF571AA00D8DB71 /* UIBarButtonItem+CC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIBarButtonItem+CC.h"; sourceTree = ""; }; 42 | 09FAEE151CF571AA00D8DB71 /* UIBarButtonItem+CC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIBarButtonItem+CC.m"; sourceTree = ""; }; 43 | 09FAEE161CF571AA00D8DB71 /* CCNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNavigationController.h; sourceTree = ""; }; 44 | 09FAEE171CF571AA00D8DB71 /* CCNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCNavigationController.m; sourceTree = ""; }; 45 | 09FAEE181CF571AA00D8DB71 /* CCTabBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTabBar.h; sourceTree = ""; }; 46 | 09FAEE191CF571AA00D8DB71 /* CCTabBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCTabBar.m; sourceTree = ""; }; 47 | 09FAEE1A1CF571AA00D8DB71 /* CCTabController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTabController.h; sourceTree = ""; }; 48 | 09FAEE1B1CF571AA00D8DB71 /* CCTabController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCTabController.m; sourceTree = ""; }; 49 | 09FAEE1C1CF571AA00D8DB71 /* CCTabItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTabItem.h; sourceTree = ""; }; 50 | 09FAEE1D1CF571AA00D8DB71 /* CCTabItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCTabItem.m; sourceTree = ""; }; 51 | /* End PBXFileReference section */ 52 | 53 | /* Begin PBXFrameworksBuildPhase section */ 54 | 090A81E91CC31C2F002F6EE2 /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | /* End PBXFrameworksBuildPhase section */ 62 | 63 | /* Begin PBXGroup section */ 64 | 090A81E31CC31C2F002F6EE2 = { 65 | isa = PBXGroup; 66 | children = ( 67 | 090A81EE1CC31C2F002F6EE2 /* CCNavTab */, 68 | 090A81ED1CC31C2F002F6EE2 /* Products */, 69 | ); 70 | sourceTree = ""; 71 | }; 72 | 090A81ED1CC31C2F002F6EE2 /* Products */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 090A81EC1CC31C2F002F6EE2 /* CCNavTab.app */, 76 | ); 77 | name = Products; 78 | sourceTree = ""; 79 | }; 80 | 090A81EE1CC31C2F002F6EE2 /* CCNavTab */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | 090A82061CC31C4C002F6EE2 /* Classes */, 84 | 090A81FB1CC31C2F002F6EE2 /* Assets.xcassets */, 85 | 090A82001CC31C2F002F6EE2 /* Info.plist */, 86 | 090A81EF1CC31C2F002F6EE2 /* Supporting Files */, 87 | ); 88 | path = CCNavTab; 89 | sourceTree = ""; 90 | }; 91 | 090A81EF1CC31C2F002F6EE2 /* Supporting Files */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 097BDB611D13B2300098EEE8 /* LaunchScreen.storyboard */, 95 | 095FD1771D05C266005D9FCC /* AppDelegate.h */, 96 | 095FD1781D05C266005D9FCC /* AppDelegate.m */, 97 | 090A81F01CC31C2F002F6EE2 /* main.m */, 98 | ); 99 | name = "Supporting Files"; 100 | sourceTree = ""; 101 | }; 102 | 090A82061CC31C4C002F6EE2 /* Classes */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 095FD1B21D05DED8005D9FCC /* Main */, 106 | 095FD1B51D05DED8005D9FCC /* One */, 107 | 095FD1B81D05DED8005D9FCC /* Three */, 108 | 095FD1BB1D05DED8005D9FCC /* Two */, 109 | 09FAEE111CF571AA00D8DB71 /* Lib */, 110 | ); 111 | path = Classes; 112 | sourceTree = ""; 113 | }; 114 | 095FD1B21D05DED8005D9FCC /* Main */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 095FD1B31D05DED8005D9FCC /* MainController.h */, 118 | 095FD1B41D05DED8005D9FCC /* MainController.m */, 119 | ); 120 | path = Main; 121 | sourceTree = ""; 122 | }; 123 | 095FD1B51D05DED8005D9FCC /* One */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 095FD1B61D05DED8005D9FCC /* OneController.h */, 127 | 095FD1B71D05DED8005D9FCC /* OneController.m */, 128 | ); 129 | path = One; 130 | sourceTree = ""; 131 | }; 132 | 095FD1B81D05DED8005D9FCC /* Three */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 095FD1B91D05DED8005D9FCC /* ThreeController.h */, 136 | 095FD1BA1D05DED8005D9FCC /* ThreeController.m */, 137 | ); 138 | path = Three; 139 | sourceTree = ""; 140 | }; 141 | 095FD1BB1D05DED8005D9FCC /* Two */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 095FD1BC1D05DED8005D9FCC /* TwoController.h */, 145 | 095FD1BD1D05DED8005D9FCC /* TwoController.m */, 146 | ); 147 | path = Two; 148 | sourceTree = ""; 149 | }; 150 | 09FAEE111CF571AA00D8DB71 /* Lib */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 09FAEE121CF571AA00D8DB71 /* CCNavTab */, 154 | ); 155 | path = Lib; 156 | sourceTree = ""; 157 | }; 158 | 09FAEE121CF571AA00D8DB71 /* CCNavTab */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | 09FAEE131CF571AA00D8DB71 /* Category */, 162 | 09FAEE161CF571AA00D8DB71 /* CCNavigationController.h */, 163 | 09FAEE171CF571AA00D8DB71 /* CCNavigationController.m */, 164 | 09FAEE181CF571AA00D8DB71 /* CCTabBar.h */, 165 | 09FAEE191CF571AA00D8DB71 /* CCTabBar.m */, 166 | 09FAEE1A1CF571AA00D8DB71 /* CCTabController.h */, 167 | 09FAEE1B1CF571AA00D8DB71 /* CCTabController.m */, 168 | 09FAEE1C1CF571AA00D8DB71 /* CCTabItem.h */, 169 | 09FAEE1D1CF571AA00D8DB71 /* CCTabItem.m */, 170 | ); 171 | path = CCNavTab; 172 | sourceTree = ""; 173 | }; 174 | 09FAEE131CF571AA00D8DB71 /* Category */ = { 175 | isa = PBXGroup; 176 | children = ( 177 | 09FAEE141CF571AA00D8DB71 /* UIBarButtonItem+CC.h */, 178 | 09FAEE151CF571AA00D8DB71 /* UIBarButtonItem+CC.m */, 179 | ); 180 | path = Category; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXGroup section */ 184 | 185 | /* Begin PBXNativeTarget section */ 186 | 090A81EB1CC31C2F002F6EE2 /* CCNavTab */ = { 187 | isa = PBXNativeTarget; 188 | buildConfigurationList = 090A82031CC31C2F002F6EE2 /* Build configuration list for PBXNativeTarget "CCNavTab" */; 189 | buildPhases = ( 190 | 090A81E81CC31C2F002F6EE2 /* Sources */, 191 | 090A81E91CC31C2F002F6EE2 /* Frameworks */, 192 | 090A81EA1CC31C2F002F6EE2 /* Resources */, 193 | ); 194 | buildRules = ( 195 | ); 196 | dependencies = ( 197 | ); 198 | name = CCNavTab; 199 | productName = CCNavTab; 200 | productReference = 090A81EC1CC31C2F002F6EE2 /* CCNavTab.app */; 201 | productType = "com.apple.product-type.application"; 202 | }; 203 | /* End PBXNativeTarget section */ 204 | 205 | /* Begin PBXProject section */ 206 | 090A81E41CC31C2F002F6EE2 /* Project object */ = { 207 | isa = PBXProject; 208 | attributes = { 209 | LastUpgradeCheck = 0720; 210 | ORGANIZATIONNAME = bear; 211 | TargetAttributes = { 212 | 090A81EB1CC31C2F002F6EE2 = { 213 | CreatedOnToolsVersion = 7.2; 214 | }; 215 | }; 216 | }; 217 | buildConfigurationList = 090A81E71CC31C2F002F6EE2 /* Build configuration list for PBXProject "CCNavTab" */; 218 | compatibilityVersion = "Xcode 3.2"; 219 | developmentRegion = English; 220 | hasScannedForEncodings = 0; 221 | knownRegions = ( 222 | en, 223 | Base, 224 | ); 225 | mainGroup = 090A81E31CC31C2F002F6EE2; 226 | productRefGroup = 090A81ED1CC31C2F002F6EE2 /* Products */; 227 | projectDirPath = ""; 228 | projectRoot = ""; 229 | targets = ( 230 | 090A81EB1CC31C2F002F6EE2 /* CCNavTab */, 231 | ); 232 | }; 233 | /* End PBXProject section */ 234 | 235 | /* Begin PBXResourcesBuildPhase section */ 236 | 090A81EA1CC31C2F002F6EE2 /* Resources */ = { 237 | isa = PBXResourcesBuildPhase; 238 | buildActionMask = 2147483647; 239 | files = ( 240 | 090A81FC1CC31C2F002F6EE2 /* Assets.xcassets in Resources */, 241 | 097BDB631D13B2300098EEE8 /* LaunchScreen.storyboard in Resources */, 242 | ); 243 | runOnlyForDeploymentPostprocessing = 0; 244 | }; 245 | /* End PBXResourcesBuildPhase section */ 246 | 247 | /* Begin PBXSourcesBuildPhase section */ 248 | 090A81E81CC31C2F002F6EE2 /* Sources */ = { 249 | isa = PBXSourcesBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | 095FD1C01D05DED8005D9FCC /* ThreeController.m in Sources */, 253 | 095FD1791D05C266005D9FCC /* AppDelegate.m in Sources */, 254 | 09FAEE221CF571AA00D8DB71 /* CCTabItem.m in Sources */, 255 | 09FAEE211CF571AA00D8DB71 /* CCTabController.m in Sources */, 256 | 09FAEE1E1CF571AA00D8DB71 /* UIBarButtonItem+CC.m in Sources */, 257 | 095FD1BE1D05DED8005D9FCC /* MainController.m in Sources */, 258 | 095FD1C11D05DED8005D9FCC /* TwoController.m in Sources */, 259 | 095FD1BF1D05DED8005D9FCC /* OneController.m in Sources */, 260 | 09FAEE201CF571AA00D8DB71 /* CCTabBar.m in Sources */, 261 | 09FAEE1F1CF571AA00D8DB71 /* CCNavigationController.m in Sources */, 262 | 090A81F11CC31C2F002F6EE2 /* main.m in Sources */, 263 | ); 264 | runOnlyForDeploymentPostprocessing = 0; 265 | }; 266 | /* End PBXSourcesBuildPhase section */ 267 | 268 | /* Begin PBXVariantGroup section */ 269 | 097BDB611D13B2300098EEE8 /* LaunchScreen.storyboard */ = { 270 | isa = PBXVariantGroup; 271 | children = ( 272 | 097BDB621D13B2300098EEE8 /* Base */, 273 | ); 274 | name = LaunchScreen.storyboard; 275 | sourceTree = ""; 276 | }; 277 | /* End PBXVariantGroup section */ 278 | 279 | /* Begin XCBuildConfiguration section */ 280 | 090A82011CC31C2F002F6EE2 /* Debug */ = { 281 | isa = XCBuildConfiguration; 282 | buildSettings = { 283 | ALWAYS_SEARCH_USER_PATHS = NO; 284 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 285 | CLANG_CXX_LIBRARY = "libc++"; 286 | CLANG_ENABLE_MODULES = YES; 287 | CLANG_ENABLE_OBJC_ARC = YES; 288 | CLANG_WARN_BOOL_CONVERSION = YES; 289 | CLANG_WARN_CONSTANT_CONVERSION = YES; 290 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 291 | CLANG_WARN_EMPTY_BODY = YES; 292 | CLANG_WARN_ENUM_CONVERSION = YES; 293 | CLANG_WARN_INT_CONVERSION = YES; 294 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 295 | CLANG_WARN_UNREACHABLE_CODE = YES; 296 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 297 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 298 | COPY_PHASE_STRIP = NO; 299 | DEBUG_INFORMATION_FORMAT = dwarf; 300 | ENABLE_STRICT_OBJC_MSGSEND = YES; 301 | ENABLE_TESTABILITY = YES; 302 | GCC_C_LANGUAGE_STANDARD = gnu99; 303 | GCC_DYNAMIC_NO_PIC = NO; 304 | GCC_NO_COMMON_BLOCKS = YES; 305 | GCC_OPTIMIZATION_LEVEL = 0; 306 | GCC_PREPROCESSOR_DEFINITIONS = ( 307 | "DEBUG=1", 308 | "$(inherited)", 309 | ); 310 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 311 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 312 | GCC_WARN_UNDECLARED_SELECTOR = YES; 313 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 314 | GCC_WARN_UNUSED_FUNCTION = YES; 315 | GCC_WARN_UNUSED_VARIABLE = YES; 316 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 317 | MTL_ENABLE_DEBUG_INFO = YES; 318 | ONLY_ACTIVE_ARCH = YES; 319 | SDKROOT = iphoneos; 320 | TARGETED_DEVICE_FAMILY = "1,2"; 321 | }; 322 | name = Debug; 323 | }; 324 | 090A82021CC31C2F002F6EE2 /* Release */ = { 325 | isa = XCBuildConfiguration; 326 | buildSettings = { 327 | ALWAYS_SEARCH_USER_PATHS = NO; 328 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 329 | CLANG_CXX_LIBRARY = "libc++"; 330 | CLANG_ENABLE_MODULES = YES; 331 | CLANG_ENABLE_OBJC_ARC = YES; 332 | CLANG_WARN_BOOL_CONVERSION = YES; 333 | CLANG_WARN_CONSTANT_CONVERSION = YES; 334 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 335 | CLANG_WARN_EMPTY_BODY = YES; 336 | CLANG_WARN_ENUM_CONVERSION = YES; 337 | CLANG_WARN_INT_CONVERSION = YES; 338 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 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 = 6.0; 355 | MTL_ENABLE_DEBUG_INFO = NO; 356 | SDKROOT = iphoneos; 357 | TARGETED_DEVICE_FAMILY = "1,2"; 358 | VALIDATE_PRODUCT = YES; 359 | }; 360 | name = Release; 361 | }; 362 | 090A82041CC31C2F002F6EE2 /* Debug */ = { 363 | isa = XCBuildConfiguration; 364 | buildSettings = { 365 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 366 | INFOPLIST_FILE = CCNavTab/Info.plist; 367 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 368 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 369 | PRODUCT_BUNDLE_IDENTIFIER = com.xiongcaichang.CCNavTab; 370 | PRODUCT_NAME = "$(TARGET_NAME)"; 371 | }; 372 | name = Debug; 373 | }; 374 | 090A82051CC31C2F002F6EE2 /* Release */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 378 | INFOPLIST_FILE = CCNavTab/Info.plist; 379 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 380 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 381 | PRODUCT_BUNDLE_IDENTIFIER = com.xiongcaichang.CCNavTab; 382 | PRODUCT_NAME = "$(TARGET_NAME)"; 383 | }; 384 | name = Release; 385 | }; 386 | /* End XCBuildConfiguration section */ 387 | 388 | /* Begin XCConfigurationList section */ 389 | 090A81E71CC31C2F002F6EE2 /* Build configuration list for PBXProject "CCNavTab" */ = { 390 | isa = XCConfigurationList; 391 | buildConfigurations = ( 392 | 090A82011CC31C2F002F6EE2 /* Debug */, 393 | 090A82021CC31C2F002F6EE2 /* Release */, 394 | ); 395 | defaultConfigurationIsVisible = 0; 396 | defaultConfigurationName = Release; 397 | }; 398 | 090A82031CC31C2F002F6EE2 /* Build configuration list for PBXNativeTarget "CCNavTab" */ = { 399 | isa = XCConfigurationList; 400 | buildConfigurations = ( 401 | 090A82041CC31C2F002F6EE2 /* Debug */, 402 | 090A82051CC31C2F002F6EE2 /* Release */, 403 | ); 404 | defaultConfigurationIsVisible = 0; 405 | defaultConfigurationName = Release; 406 | }; 407 | /* End XCConfigurationList section */ 408 | }; 409 | rootObject = 090A81E41CC31C2F002F6EE2 /* Project object */; 410 | } 411 | -------------------------------------------------------------------------------- /Demo/CCNavTab.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo/CCNavTab.xcodeproj/xcuserdata/bear.xcuserdatad/xcschemes/CCNavTab.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 | -------------------------------------------------------------------------------- /Demo/CCNavTab.xcodeproj/xcuserdata/bear.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CCNavTab.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 090A81EB1CC31C2F002F6EE2 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Demo/CCNavTab/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // XCNavTabDemo 4 | // 5 | // Created by bear on 16/3/29. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MainController.h" 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (strong, nonatomic) UIWindow *window; 15 | 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /Demo/CCNavTab/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // XCNavTabDemo 4 | // 5 | // Created by bear on 16/3/29. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | 21 | self.window=[[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; 22 | 23 | 24 | MainController *mainVc=[[MainController alloc]init]; 25 | 26 | self.window.backgroundColor=[UIColor whiteColor]; 27 | 28 | self.window.rootViewController=mainVc; 29 | 30 | //设置为主控制器并可见 31 | [self.window makeKeyAndVisible]; 32 | 33 | return YES; 34 | } 35 | 36 | 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Demo/CCNavTab/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 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/background.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "tabbar_background.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/background.imageset/tabbar_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/background.imageset/tabbar_background.png -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_classTable.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "icon_classTable@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "icon_classTable@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_classTable.imageset/icon_classTable@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/tab/icon_classTable.imageset/icon_classTable@2x.png -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_classTable.imageset/icon_classTable@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/tab/icon_classTable.imageset/icon_classTable@3x.png -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_classTable_selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "icon_classTable_selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "icon_classTable_selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_classTable_selected.imageset/icon_classTable_selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/tab/icon_classTable_selected.imageset/icon_classTable_selected@2x.png -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_classTable_selected.imageset/icon_classTable_selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/tab/icon_classTable_selected.imageset/icon_classTable_selected@3x.png -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_discover.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "icon_discover@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "icon_discover@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_discover.imageset/icon_discover@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/tab/icon_discover.imageset/icon_discover@2x.png -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_discover.imageset/icon_discover@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/tab/icon_discover.imageset/icon_discover@3x.png -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_discover_selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "icon_discover_selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "icon_discover_selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_discover_selected.imageset/icon_discover_selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/tab/icon_discover_selected.imageset/icon_discover_selected@2x.png -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_discover_selected.imageset/icon_discover_selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/tab/icon_discover_selected.imageset/icon_discover_selected@3x.png -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_me.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "icon_me@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "icon_me@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_me.imageset/icon_me@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/tab/icon_me.imageset/icon_me@2x.png -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_me.imageset/icon_me@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/tab/icon_me.imageset/icon_me@3x.png -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_me_selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "icon_me_selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "icon_me_selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_me_selected.imageset/icon_me_selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/tab/icon_me_selected.imageset/icon_me_selected@2x.png -------------------------------------------------------------------------------- /Demo/CCNavTab/Assets.xcassets/tab/icon_me_selected.imageset/icon_me_selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/Demo/CCNavTab/Assets.xcassets/tab/icon_me_selected.imageset/icon_me_selected@3x.png -------------------------------------------------------------------------------- /Demo/CCNavTab/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 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Lib/CCNavTab/CCNavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CCNavigationController.h 3 | // CCNavTab 4 | // 5 | // Created by bear on 16/3/24. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CCNavigationController : UINavigationController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Lib/CCNavTab/CCNavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CCNavigationController.m 3 | // CCNavTab 4 | // 5 | // Created by bear on 16/3/24. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "CCNavigationController.h" 10 | 11 | 12 | #define CCTabBarNotifacationIsHiden @"CCTabBarHiden" 13 | 14 | @interface CCNavigationController () 15 | 16 | @end 17 | 18 | @implementation CCNavigationController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | 23 | 24 | 25 | self.navigationBar.shadowImage=[[UIImage alloc]init]; 26 | 27 | 28 | } 29 | 30 | 31 | 32 | 33 | 34 | - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated 35 | { 36 | 37 | // self - 导航控制器 38 | if (self.viewControllers.count) { // 不是根控制器 39 | 40 | viewController.hidesBottomBarWhenPushed = YES; 41 | } 42 | 43 | 44 | UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; 45 | self.topViewController.navigationItem.backBarButtonItem = backItem; 46 | 47 | 48 | // 调用系统默认做法,因为只有系统才知道怎么做push 49 | [super pushViewController:viewController animated:animated]; 50 | } 51 | 52 | 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Lib/CCNavTab/CCTabBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+XCC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CCTabItem.h" 11 | 12 | #define kTabBarHeight 49 13 | 14 | @class CCTabBar; 15 | 16 | 17 | 18 | @protocol CCTabBarDelegate 19 | 20 | @optional 21 | -(void)tabbar:(CCTabBar *)tabbar to:(NSInteger)to; 22 | 23 | @end 24 | 25 | 26 | 27 | 28 | @interface CCTabBar : UIView 29 | 30 | @property (nonatomic, weak) CCTabItem *selectedItem; 31 | 32 | //添加tab按钮的方法 33 | -(void)addItemWithIcon:(NSString *)icon selectedIcon:(NSString *)icon_selected title:(NSString *)title; 34 | 35 | @property (nonatomic,weak) id delegate; 36 | 37 | @end 38 | 39 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Lib/CCNavTab/CCTabBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+XCC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "CCTabBar.h" 10 | #import "CCTabItem.h" 11 | 12 | @implementation CCTabBar 13 | 14 | 15 | - (void)addItemWithIcon:(NSString *)icon selectedIcon:(NSString *)selected title:(NSString *)title 16 | { 17 | // 1.创建item 18 | CCTabItem *item = [[CCTabItem alloc] init]; 19 | 20 | 21 | // 文字 22 | [item setTitle:title forState:UIControlStateNormal]; 23 | item.titleLabel.textColor=[UIColor lightGrayColor]; 24 | 25 | // 图标 26 | [item setImage:[UIImage imageNamed:icon] forState:UIControlStateNormal]; 27 | [item setImage:[UIImage imageNamed:selected] forState:UIControlStateSelected]; 28 | 29 | // 监听item的点击 30 | [item addTarget:self action:@selector(itemClick:) forControlEvents:UIControlEventTouchDown]; 31 | 32 | // 2.添加item 33 | [self addSubview:item]; 34 | NSInteger count = self.subviews.count; 35 | 36 | // 默认选中第一个item 37 | if (count == 1) { 38 | [self itemClick:item]; 39 | } 40 | 41 | // 3.调整所有item的frame 42 | CGFloat height = self.frame.size.height; // 高度 43 | CGFloat width = self.frame.size.width / count; // 宽度 44 | for (int i = 0; i 10 | #import "CCTabBar.h" 11 | 12 | #define ACTION_NAME @"action_name" 13 | 14 | #define VIEWCONTROLLER @"VC" 15 | 16 | #define NORMAL_ICON @"ICONOR" 17 | 18 | #define SELECTED_ICON @"ICONSE" 19 | 20 | #define TITLE @"TITLE" 21 | 22 | 23 | @interface CCTabController :UITabBarController{ 24 | @public 25 | 26 | CCTabBar *_tabBar; 27 | } 28 | 29 | 30 | 31 | //子控制器信息数组 32 | @property (nonatomic, strong) NSArray *childControllerAndIconArr; 33 | 34 | 35 | /** 36 | 配置导航栏的颜色/图片 37 | 注意:当背景颜色设置时图片不生效 navigationBarBackgroundColor navigationBarBackgroundImage一般二选其一 默认为系统白色 38 | */ 39 | @property (nonatomic, strong) UIColor *navigationBarBackgroundColor; 40 | 41 | @property (nonatomic, strong) UIImage *navigationBarBackgroundImage; 42 | 43 | /** 44 | 可选配置 45 | 导航栏文字颜色 Title 和 BarButtonItem 默认为黑色 46 | */ 47 | @property (nonatomic, strong) UIColor *navigationBarTintColor; 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Lib/CCNavTab/CCTabController.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | #import "CCTabController.h" 9 | #import "CCNavigationController.h" 10 | #import "CCTabItem.h" 11 | 12 | 13 | @interface CCTabController () 14 | 15 | 16 | 17 | 18 | @end 19 | 20 | @implementation CCTabController 21 | 22 | 23 | - (void)viewDidLoad 24 | { 25 | [super viewDidLoad]; 26 | 27 | // 初始化TabBar 28 | [self initTabBar]; 29 | 30 | } 31 | 32 | 33 | - (void)viewWillAppear:(BOOL)animated 34 | { 35 | // 调用系统默认的做法:添加UITabBarButton 36 | [super viewWillAppear:animated]; 37 | 38 | // 删除self.tabBar中的子控件除了自定义tabBar 39 | for (UIView *childView in self.tabBar.subviews) { 40 | if (![childView isKindOfClass:[CCTabBar class]] && ![childView isKindOfClass:[UIImageView class]]) { // 不是自己的tabBar 41 | 42 | [childView removeFromSuperview]; 43 | } 44 | 45 | } 46 | 47 | } 48 | 49 | 50 | 51 | #pragma mark 初始化TabBar 52 | - (void)initTabBar 53 | { 54 | 55 | CCTabBar *tabBar = [[CCTabBar alloc] initWithFrame:self.tabBar.bounds]; 56 | 57 | tabBar.delegate=self; 58 | 59 | [self.tabBar addSubview:tabBar]; 60 | 61 | _tabBar=tabBar; 62 | 63 | } 64 | 65 | 66 | 67 | 68 | #pragma mark tabBar的代理方法 69 | - (void)tabbar:(CCTabBar *)tabbar to:(NSInteger)to{ 70 | 71 | if (to < 0 || to >= self.childViewControllers.count||self.selectedIndex==to) return; 72 | 73 | UIViewController *newVc = self.childViewControllers[to]; 74 | 75 | CGFloat width = self.view.frame.size.width; 76 | 77 | CGFloat height=height = self.view.frame.size.height; 78 | 79 | newVc.view.frame = CGRectMake(0,0, width, height); 80 | 81 | self.selectedIndex=to; 82 | 83 | [self.view bringSubviewToFront:_tabBar]; 84 | 85 | } 86 | 87 | 88 | 89 | 90 | 91 | -(void)setChildControllerAndIconArr:(NSArray *)childControllerAndIconArr{ 92 | 93 | _childControllerAndIconArr=childControllerAndIconArr; 94 | 95 | //遍历配置字典 96 | for (NSInteger i = 0; i < childControllerAndIconArr.count; i++) { 97 | 98 | //取出字典 99 | NSDictionary *dict=childControllerAndIconArr[i]; 100 | 101 | 102 | 103 | UIViewController *vc = [dict objectForKey:VIEWCONTROLLER]; 104 | 105 | 106 | [vc addObserver:self forKeyPath:@"tabBarItem.badgeValue" options:NSKeyValueObservingOptionNew context:NULL]; 107 | 108 | 109 | CCNavigationController *nav=[[CCNavigationController alloc]initWithRootViewController:vc]; 110 | 111 | [vc setTitle:[dict objectForKey:TITLE]]; 112 | 113 | [self addChildViewController:nav]; 114 | 115 | 116 | if (self.navigationBarBackgroundColor == nil) { 117 | 118 | [nav.navigationBar setBackgroundImage:self.navigationBarBackgroundImage forBarMetrics:UIBarMetricsDefault]; 119 | 120 | }else{ 121 | 122 | [nav.navigationBar setBarTintColor:self.navigationBarBackgroundColor]; 123 | 124 | } 125 | 126 | 127 | [nav.navigationBar setTintColor:self.navigationBarTintColor]; 128 | 129 | [nav.navigationItem.backBarButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName:self.navigationBarTintColor} forState:UIControlStateNormal]; 130 | 131 | nav.navigationBar.titleTextAttributes=@{NSForegroundColorAttributeName:self.navigationBarTintColor}; 132 | 133 | 134 | 135 | 136 | [_tabBar addItemWithIcon:[dict objectForKey:NORMAL_ICON] selectedIcon:[dict objectForKey:SELECTED_ICON] title:[dict objectForKey:TITLE]]; 137 | 138 | } 139 | } 140 | 141 | 142 | 143 | 144 | -(UIColor *)navigationBarTintColor{ 145 | if (!_navigationBarTintColor) { 146 | _navigationBarTintColor = [UIColor blackColor]; 147 | } 148 | 149 | return _navigationBarTintColor; 150 | } 151 | 152 | 153 | -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ 154 | if ([keyPath isEqualToString:@"tabBarItem.badgeValue"]) { 155 | 156 | //遍历配置字典 157 | for (NSInteger i = 0; i < self.childControllerAndIconArr.count; i++) { 158 | 159 | //取出字典 160 | NSDictionary *dict=self.childControllerAndIconArr[i]; 161 | 162 | UIViewController *vc = [dict objectForKey:VIEWCONTROLLER]; 163 | 164 | if ([vc isEqual:object]) { 165 | 166 | for (CCTabItem *item in _tabBar.subviews) { 167 | if (item.tag==i) { 168 | if ([change[@"new"] isEqualToString:@"0"]) { 169 | item.bageView.hidden=YES; 170 | }else{ 171 | item.bageView.hidden=NO; 172 | item.bageView.text=change[@"new"]; 173 | } 174 | 175 | } 176 | } 177 | } 178 | 179 | 180 | } 181 | } 182 | 183 | } 184 | 185 | 186 | -(void)dealloc{ 187 | for (NSInteger i = 0; i < self.childControllerAndIconArr.count; i++) { 188 | 189 | NSDictionary *dict=self.childControllerAndIconArr[i]; 190 | 191 | UIViewController *vc = [dict objectForKey:VIEWCONTROLLER]; 192 | [vc removeObserver:self forKeyPath:@"tabBarItem.badgeValue"]; 193 | } 194 | 195 | } 196 | 197 | @end 198 | 199 | 200 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Lib/CCNavTab/CCTabItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CCTabItem : UIButton 12 | 13 | @property (nonatomic, weak) UILabel *bageView; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Lib/CCNavTab/CCTabItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "CCTabItem.h" 10 | 11 | #define kDockItemSelectedBG @"tabbar_slider.png" 12 | 13 | // 文字的高度比例 14 | #define kTitleRatio 0.3 15 | 16 | @interface CCTabItem() 17 | 18 | 19 | 20 | 21 | @end 22 | 23 | 24 | @implementation CCTabItem 25 | - (id)initWithFrame:(CGRect)frame 26 | { 27 | self = [super initWithFrame:frame]; 28 | if (self) { 29 | // 1.文字居中 30 | self.titleLabel.textAlignment = NSTextAlignmentCenter; 31 | 32 | // 2.文字大小 33 | CGFloat fontSize=([UIScreen mainScreen].bounds.size.width/414.0)*12; 34 | self.titleLabel.font = [UIFont systemFontOfSize:fontSize]; 35 | [self setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; 36 | 37 | // 3.图片的内容模式 38 | self.imageView.contentMode = UIViewContentModeScaleToFill; 39 | 40 | 41 | //4.添加 bageView 42 | UILabel *label=[[UILabel alloc]init]; 43 | label.layer.cornerRadius=10; 44 | label.font=[UIFont systemFontOfSize:10]; 45 | label.layer.masksToBounds=YES; 46 | label.textAlignment=NSTextAlignmentCenter; 47 | label.backgroundColor=[UIColor redColor]; 48 | label.hidden=YES; 49 | 50 | label.textColor=[UIColor whiteColor]; 51 | [self addSubview:label]; 52 | self.bageView=label; 53 | 54 | 55 | } 56 | return self; 57 | } 58 | 59 | 60 | 61 | 62 | 63 | 64 | #pragma mark 覆盖父类在highlighted时的所有操作 65 | - (void)setHighlighted:(BOOL)highlighted { 66 | [super setHighlighted:highlighted]; 67 | } 68 | 69 | #pragma mark 调整内部ImageView的frame 70 | - (CGRect)imageRectForContentRect:(CGRect)contentRect 71 | { 72 | 73 | CGFloat imageX = (contentRect.size.width-27)*0.5; 74 | CGFloat imageY = 3; 75 | CGFloat imageWidth = 27; 76 | CGFloat imageHeight = 27; 77 | 78 | self.bageView.frame=CGRectMake(imageX+imageWidth+3, 5, 20, 20); 79 | return CGRectMake(imageX, imageY, imageWidth, imageHeight); 80 | } 81 | 82 | #pragma mark 调整内部UILabel的frame 83 | - (CGRect)titleRectForContentRect:(CGRect)contentRect 84 | { 85 | CGFloat titleX = 0; 86 | 87 | CGFloat titleHeight = contentRect.size.height * kTitleRatio; 88 | CGFloat titleY = contentRect.size.height - titleHeight - 3; 89 | CGFloat titleWidth = contentRect.size.width; 90 | return CGRectMake(titleX, titleY, titleWidth, titleHeight); 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Lib/CCNavTab/Category/UIBarButtonItem+CC.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIBarButtonItem (CC) 12 | /** 13 | * 快速创建item 14 | */ 15 | + (UIBarButtonItem *)itemWithImage:(UIImage *)image highImage:(UIImage *)highImage target:(id)target action:(SEL)action; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Lib/CCNavTab/Category/UIBarButtonItem+CC.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "UIBarButtonItem+CC.h" 10 | 11 | @implementation UIBarButtonItem (CC) 12 | 13 | + (UIBarButtonItem *)itemWithImage:(UIImage *)image highImage:(UIImage *)highImage target:(id)target action:(SEL)action 14 | { 15 | UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 16 | [button setBackgroundImage:image forState:UIControlStateNormal]; 17 | [button setBackgroundImage:highImage forState:UIControlStateHighlighted]; 18 | [button setFrame:CGRectMake(0, 0, 44, 44)]; 19 | [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside]; 20 | return [[UIBarButtonItem alloc] initWithCustomView:button]; 21 | 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Main/MainController.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "CCTabController.h" 10 | 11 | @interface MainController : CCTabController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Main/MainController.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "MainController.h" 10 | //准备工作 导入头文件 11 | #import "OneController.h" 12 | #import "TwoController.h" 13 | 14 | @interface MainController () 15 | 16 | @end 17 | 18 | @implementation MainController 19 | 20 | 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | 25 | 26 | /** 27 | 配置导航栏的颜色/图片 28 | 注意:当背景颜色设置时图片不生效 一般二选其一 默认为系统白色 29 | */ 30 | self.navigationBarBackgroundColor=[UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1]; 31 | 32 | //self.navigationBarBackgroundImage = [UIImage imageNamed:@"background"] ; 33 | 34 | /** 35 | 可选配置 36 | 导航栏文字颜色 Title 和 BarButtonItem 默认为黑色 37 | */ 38 | self.navigationBarTintColor = [UIColor whiteColor]; 39 | 40 | 41 | 42 | /** 43 | .第二步: 初始化控制器 添加子控制器配置数组 可以添加任意个,但是最好不要超过6个 44 | 45 | */ 46 | 47 | self.childControllerAndIconArr=@[ 48 | /************第一个控制器配置信息*********************/ 49 | @{ 50 | VIEWCONTROLLER :[[OneController alloc]init], //控制器对象 51 | NORMAL_ICON : @"icon_classTable", //正常状态的Icon 名称 52 | SELECTED_ICON : @"icon_classTable_selected", //选中状态的Icon 名称 53 | TITLE : @"表" //Nav和Tab的标题 54 | }, 55 | /************第二个控制器配置信息*********************/ 56 | @{ 57 | VIEWCONTROLLER : [[TwoController alloc]init], 58 | NORMAL_ICON : @"icon_me", 59 | SELECTED_ICON : @"icon_me_selected", 60 | TITLE : @"校园" 61 | }, 62 | ]; 63 | 64 | 65 | } 66 | 67 | 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/One/OneController.h: -------------------------------------------------------------------------------- 1 | // 2 | // OneController.h 3 | // XCNavTabDemo 4 | // 5 | // Created by bear on 16/3/29. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OneController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/One/OneController.m: -------------------------------------------------------------------------------- 1 | // 2 | // OneController.m 3 | // XCNavTabDemo 4 | // 5 | // Created by bear on 16/3/29. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "OneController.h" 10 | #import "ThreeController.h" 11 | 12 | @interface OneController () 13 | 14 | @property (nonatomic, strong) NSMutableArray *arrayM; 15 | 16 | 17 | @end 18 | 19 | @implementation OneController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | 24 | 25 | 26 | self.view.backgroundColor=[UIColor whiteColor]; 27 | 28 | 29 | 30 | UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom]; 31 | button.frame=CGRectMake(0, 0, 200, 60); 32 | button.center=self.view.center; 33 | 34 | button.backgroundColor=[UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1]; 35 | 36 | 37 | [button setTitle:@"点击跳转" forState:UIControlStateNormal]; 38 | [self.view addSubview:button]; 39 | 40 | [button addTarget:self action:@selector(jumpToThree) forControlEvents:UIControlEventTouchUpInside]; 41 | 42 | 43 | } 44 | 45 | 46 | -(void)jumpToThree{ 47 | [self.navigationController pushViewController:[[ThreeController alloc]init] animated:YES]; 48 | } 49 | 50 | 51 | 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Three/ThreeController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ThreeController.h 3 | // XCNavTabDemo 4 | // 5 | // Created by bear on 16/3/30. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ThreeController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Three/ThreeController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ThreeController.m 3 | // XCNavTabDemo 4 | // 5 | // Created by bear on 16/3/30. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "ThreeController.h" 10 | 11 | 12 | @implementation ThreeController 13 | 14 | - (void)viewDidLoad { 15 | [super viewDidLoad]; 16 | self.title=@"子控制器"; 17 | self.view.backgroundColor=[UIColor whiteColor]; 18 | 19 | 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Two/TwoController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TwoController.h 3 | // XCNavTabDemo 4 | // 5 | // Created by bear on 16/3/29. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TwoController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Demo/CCNavTab/Classes/Two/TwoController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TwoController.m 3 | // XCNavTabDemo 4 | // 5 | // Created by bear on 16/3/29. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "TwoController.h" 10 | 11 | @interface TwoController () 12 | 13 | @end 14 | 15 | @implementation TwoController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | self.tabBarItem.badgeValue=@"6"; 21 | 22 | UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom]; 23 | button.frame=CGRectMake(0, 0, 200, 60); 24 | button.center=self.view.center; 25 | button.backgroundColor=[UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1]; 26 | 27 | [button setTitle:@"改变 bageView" forState:UIControlStateNormal]; 28 | [self.view addSubview:button]; 29 | 30 | [button addTarget:self action:@selector(changeBageView) forControlEvents:UIControlEventTouchUpInside]; 31 | } 32 | 33 | 34 | -(void)changeBageView{ 35 | if ([self.tabBarItem.badgeValue isEqualToString:@"0"]) { 36 | self.tabBarItem.badgeValue=@"6"; 37 | }else{ 38 | self.tabBarItem.badgeValue=@"0"; 39 | } 40 | } 41 | 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Demo/CCNavTab/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 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Demo/CCNavTab/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CCNavTab 4 | // 5 | // Created by bear on 16/4/17. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /Lib/CCNavTab/CCNavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CCNavigationController.h 3 | // CCNavTab 4 | // 5 | // Created by bear on 16/3/24. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CCNavigationController : UINavigationController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Lib/CCNavTab/CCNavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CCNavigationController.m 3 | // CCNavTab 4 | // 5 | // Created by bear on 16/3/24. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "CCNavigationController.h" 10 | 11 | 12 | #define CCTabBarNotifacationIsHiden @"CCTabBarHiden" 13 | 14 | @interface CCNavigationController () 15 | 16 | @end 17 | 18 | @implementation CCNavigationController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | 23 | 24 | 25 | self.navigationBar.shadowImage=[[UIImage alloc]init]; 26 | 27 | 28 | } 29 | 30 | 31 | 32 | 33 | 34 | - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated 35 | { 36 | 37 | // self - 导航控制器 38 | if (self.viewControllers.count) { // 不是根控制器 39 | 40 | viewController.hidesBottomBarWhenPushed = YES; 41 | } 42 | 43 | 44 | UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; 45 | self.topViewController.navigationItem.backBarButtonItem = backItem; 46 | 47 | 48 | // 调用系统默认做法,因为只有系统才知道怎么做push 49 | [super pushViewController:viewController animated:animated]; 50 | } 51 | 52 | 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /Lib/CCNavTab/CCTabBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+XCC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CCTabItem.h" 11 | 12 | #define kTabBarHeight 49 13 | 14 | @class CCTabBar; 15 | 16 | 17 | 18 | @protocol CCTabBarDelegate 19 | 20 | @optional 21 | -(void)tabbar:(CCTabBar *)tabbar to:(NSInteger)to; 22 | 23 | @end 24 | 25 | 26 | 27 | 28 | @interface CCTabBar : UIView 29 | 30 | @property (nonatomic, weak) CCTabItem *selectedItem; 31 | 32 | //添加tab按钮的方法 33 | -(void)addItemWithIcon:(NSString *)icon selectedIcon:(NSString *)icon_selected title:(NSString *)title; 34 | 35 | @property (nonatomic,weak) id delegate; 36 | 37 | @end 38 | 39 | -------------------------------------------------------------------------------- /Lib/CCNavTab/CCTabBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+XCC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "CCTabBar.h" 10 | #import "CCTabItem.h" 11 | 12 | @implementation CCTabBar 13 | 14 | 15 | - (void)addItemWithIcon:(NSString *)icon selectedIcon:(NSString *)selected title:(NSString *)title 16 | { 17 | // 1.创建item 18 | CCTabItem *item = [[CCTabItem alloc] init]; 19 | 20 | 21 | // 文字 22 | [item setTitle:title forState:UIControlStateNormal]; 23 | item.titleLabel.textColor=[UIColor lightGrayColor]; 24 | 25 | // 图标 26 | [item setImage:[UIImage imageNamed:icon] forState:UIControlStateNormal]; 27 | [item setImage:[UIImage imageNamed:selected] forState:UIControlStateSelected]; 28 | 29 | // 监听item的点击 30 | [item addTarget:self action:@selector(itemClick:) forControlEvents:UIControlEventTouchDown]; 31 | 32 | // 2.添加item 33 | [self addSubview:item]; 34 | NSInteger count = self.subviews.count; 35 | 36 | // 默认选中第一个item 37 | if (count == 1) { 38 | [self itemClick:item]; 39 | } 40 | 41 | // 3.调整所有item的frame 42 | CGFloat height = self.frame.size.height; // 高度 43 | CGFloat width = self.frame.size.width / count; // 宽度 44 | for (int i = 0; i 10 | #import "CCTabBar.h" 11 | 12 | #define ACTION_NAME @"action_name" 13 | 14 | #define VIEWCONTROLLER @"VC" 15 | 16 | #define NORMAL_ICON @"ICONOR" 17 | 18 | #define SELECTED_ICON @"ICONSE" 19 | 20 | #define TITLE @"TITLE" 21 | 22 | 23 | @interface CCTabController :UITabBarController{ 24 | @public 25 | 26 | CCTabBar *_tabBar; 27 | } 28 | 29 | 30 | 31 | //子控制器信息数组 32 | @property (nonatomic, strong) NSArray *childControllerAndIconArr; 33 | 34 | 35 | /** 36 | 配置导航栏的颜色/图片 37 | 注意:当背景颜色设置时图片不生效 navigationBarBackgroundColor navigationBarBackgroundImage一般二选其一 默认为系统白色 38 | */ 39 | @property (nonatomic, strong) UIColor *navigationBarBackgroundColor; 40 | 41 | @property (nonatomic, strong) UIImage *navigationBarBackgroundImage; 42 | 43 | /** 44 | 可选配置 45 | 导航栏文字颜色 Title 和 BarButtonItem 默认为黑色 46 | */ 47 | @property (nonatomic, strong) UIColor *navigationBarTintColor; 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Lib/CCNavTab/CCTabController.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | #import "CCTabController.h" 9 | #import "CCNavigationController.h" 10 | #import "CCTabItem.h" 11 | 12 | 13 | @interface CCTabController () 14 | 15 | 16 | 17 | 18 | @end 19 | 20 | @implementation CCTabController 21 | 22 | 23 | - (void)viewDidLoad 24 | { 25 | [super viewDidLoad]; 26 | 27 | // 初始化TabBar 28 | [self initTabBar]; 29 | 30 | } 31 | 32 | 33 | - (void)viewWillAppear:(BOOL)animated 34 | { 35 | // 调用系统默认的做法:添加UITabBarButton 36 | [super viewWillAppear:animated]; 37 | 38 | // 删除self.tabBar中的子控件除了自定义tabBar 39 | for (UIView *childView in self.tabBar.subviews) { 40 | if (![childView isKindOfClass:[CCTabBar class]] && ![childView isKindOfClass:[UIImageView class]]) { // 不是自己的tabBar 41 | 42 | [childView removeFromSuperview]; 43 | } 44 | 45 | } 46 | 47 | } 48 | 49 | 50 | 51 | #pragma mark 初始化TabBar 52 | - (void)initTabBar 53 | { 54 | 55 | CCTabBar *tabBar = [[CCTabBar alloc] initWithFrame:self.tabBar.bounds]; 56 | 57 | tabBar.delegate=self; 58 | 59 | [self.tabBar addSubview:tabBar]; 60 | 61 | _tabBar=tabBar; 62 | 63 | } 64 | 65 | 66 | 67 | 68 | #pragma mark tabBar的代理方法 69 | - (void)tabbar:(CCTabBar *)tabbar to:(NSInteger)to{ 70 | 71 | if (to < 0 || to >= self.childViewControllers.count||self.selectedIndex==to) return; 72 | 73 | UIViewController *newVc = self.childViewControllers[to]; 74 | 75 | CGFloat width = self.view.frame.size.width; 76 | 77 | CGFloat height=height = self.view.frame.size.height; 78 | 79 | newVc.view.frame = CGRectMake(0,0, width, height); 80 | 81 | self.selectedIndex=to; 82 | 83 | [self.view bringSubviewToFront:_tabBar]; 84 | 85 | } 86 | 87 | 88 | 89 | 90 | 91 | -(void)setChildControllerAndIconArr:(NSArray *)childControllerAndIconArr{ 92 | 93 | _childControllerAndIconArr=childControllerAndIconArr; 94 | 95 | //遍历配置字典 96 | for (NSInteger i = 0; i < childControllerAndIconArr.count; i++) { 97 | 98 | //取出字典 99 | NSDictionary *dict=childControllerAndIconArr[i]; 100 | 101 | 102 | 103 | UIViewController *vc = [dict objectForKey:VIEWCONTROLLER]; 104 | 105 | 106 | [vc addObserver:self forKeyPath:@"tabBarItem.badgeValue" options:NSKeyValueObservingOptionNew context:NULL]; 107 | 108 | 109 | CCNavigationController *nav=[[CCNavigationController alloc]initWithRootViewController:vc]; 110 | 111 | [vc setTitle:[dict objectForKey:TITLE]]; 112 | 113 | [self addChildViewController:nav]; 114 | 115 | 116 | if (self.navigationBarBackgroundColor == nil) { 117 | 118 | [nav.navigationBar setBackgroundImage:self.navigationBarBackgroundImage forBarMetrics:UIBarMetricsDefault]; 119 | 120 | }else{ 121 | 122 | [nav.navigationBar setBarTintColor:self.navigationBarBackgroundColor]; 123 | 124 | } 125 | 126 | 127 | [nav.navigationBar setTintColor:self.navigationBarTintColor]; 128 | 129 | [nav.navigationItem.backBarButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName:self.navigationBarTintColor} forState:UIControlStateNormal]; 130 | 131 | nav.navigationBar.titleTextAttributes=@{NSForegroundColorAttributeName:self.navigationBarTintColor}; 132 | 133 | 134 | 135 | 136 | [_tabBar addItemWithIcon:[dict objectForKey:NORMAL_ICON] selectedIcon:[dict objectForKey:SELECTED_ICON] title:[dict objectForKey:TITLE]]; 137 | 138 | } 139 | } 140 | 141 | 142 | 143 | 144 | -(UIColor *)navigationBarTintColor{ 145 | if (!_navigationBarTintColor) { 146 | _navigationBarTintColor = [UIColor blackColor]; 147 | } 148 | 149 | return _navigationBarTintColor; 150 | } 151 | 152 | 153 | -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ 154 | if ([keyPath isEqualToString:@"tabBarItem.badgeValue"]) { 155 | 156 | //遍历配置字典 157 | for (NSInteger i = 0; i < self.childControllerAndIconArr.count; i++) { 158 | 159 | //取出字典 160 | NSDictionary *dict=self.childControllerAndIconArr[i]; 161 | 162 | UIViewController *vc = [dict objectForKey:VIEWCONTROLLER]; 163 | 164 | if ([vc isEqual:object]) { 165 | 166 | for (CCTabItem *item in _tabBar.subviews) { 167 | if (item.tag==i) { 168 | if ([change[@"new"] isEqualToString:@"0"]) { 169 | item.bageView.hidden=YES; 170 | }else{ 171 | item.bageView.hidden=NO; 172 | item.bageView.text=change[@"new"]; 173 | } 174 | 175 | } 176 | } 177 | } 178 | 179 | 180 | } 181 | } 182 | 183 | } 184 | 185 | 186 | -(void)dealloc{ 187 | for (NSInteger i = 0; i < self.childControllerAndIconArr.count; i++) { 188 | 189 | NSDictionary *dict=self.childControllerAndIconArr[i]; 190 | 191 | UIViewController *vc = [dict objectForKey:VIEWCONTROLLER]; 192 | [vc removeObserver:self forKeyPath:@"tabBarItem.badgeValue"]; 193 | } 194 | 195 | } 196 | 197 | @end 198 | 199 | 200 | -------------------------------------------------------------------------------- /Lib/CCNavTab/CCTabItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CCTabItem : UIButton 12 | 13 | @property (nonatomic, weak) UILabel *bageView; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Lib/CCNavTab/CCTabItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "CCTabItem.h" 10 | 11 | #define kDockItemSelectedBG @"tabbar_slider.png" 12 | 13 | // 文字的高度比例 14 | #define kTitleRatio 0.3 15 | 16 | @interface CCTabItem() 17 | 18 | 19 | 20 | 21 | @end 22 | 23 | 24 | @implementation CCTabItem 25 | - (id)initWithFrame:(CGRect)frame 26 | { 27 | self = [super initWithFrame:frame]; 28 | if (self) { 29 | // 1.文字居中 30 | self.titleLabel.textAlignment = NSTextAlignmentCenter; 31 | 32 | // 2.文字大小 33 | CGFloat fontSize=([UIScreen mainScreen].bounds.size.width/414.0)*12; 34 | self.titleLabel.font = [UIFont systemFontOfSize:fontSize]; 35 | [self setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; 36 | 37 | // 3.图片的内容模式 38 | self.imageView.contentMode = UIViewContentModeScaleToFill; 39 | 40 | 41 | //4.添加 bageView 42 | UILabel *label=[[UILabel alloc]init]; 43 | label.layer.cornerRadius=10; 44 | label.font=[UIFont systemFontOfSize:10]; 45 | label.layer.masksToBounds=YES; 46 | label.textAlignment=NSTextAlignmentCenter; 47 | label.backgroundColor=[UIColor redColor]; 48 | label.hidden=YES; 49 | 50 | label.textColor=[UIColor whiteColor]; 51 | [self addSubview:label]; 52 | self.bageView=label; 53 | 54 | 55 | } 56 | return self; 57 | } 58 | 59 | 60 | 61 | 62 | 63 | 64 | #pragma mark 覆盖父类在highlighted时的所有操作 65 | - (void)setHighlighted:(BOOL)highlighted { 66 | [super setHighlighted:highlighted]; 67 | } 68 | 69 | #pragma mark 调整内部ImageView的frame 70 | - (CGRect)imageRectForContentRect:(CGRect)contentRect 71 | { 72 | 73 | CGFloat imageX = (contentRect.size.width-27)*0.5; 74 | CGFloat imageY = 3; 75 | CGFloat imageWidth = 27; 76 | CGFloat imageHeight = 27; 77 | 78 | self.bageView.frame=CGRectMake(imageX+imageWidth+3, 5, 20, 20); 79 | return CGRectMake(imageX, imageY, imageWidth, imageHeight); 80 | } 81 | 82 | #pragma mark 调整内部UILabel的frame 83 | - (CGRect)titleRectForContentRect:(CGRect)contentRect 84 | { 85 | CGFloat titleX = 0; 86 | 87 | CGFloat titleHeight = contentRect.size.height * kTitleRatio; 88 | CGFloat titleY = contentRect.size.height - titleHeight - 3; 89 | CGFloat titleWidth = contentRect.size.width; 90 | return CGRectMake(titleX, titleY, titleWidth, titleHeight); 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /Lib/CCNavTab/Category/UIBarButtonItem+CC.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIBarButtonItem (CC) 12 | /** 13 | * 快速创建item 14 | */ 15 | + (UIBarButtonItem *)itemWithImage:(UIImage *)image highImage:(UIImage *)highImage target:(id)target action:(SEL)action; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Lib/CCNavTab/Category/UIBarButtonItem+CC.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+CC.m 3 | // CCNavTab 4 | // url:https://github.com/xiongcaichang/CCNavTab 5 | // Created by bear on 16/3/31. 6 | // Copyright © 2016年 bear. All rights reserved. 7 | // 8 | 9 | #import "UIBarButtonItem+CC.h" 10 | 11 | @implementation UIBarButtonItem (CC) 12 | 13 | + (UIBarButtonItem *)itemWithImage:(UIImage *)image highImage:(UIImage *)highImage target:(id)target action:(SEL)action 14 | { 15 | UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 16 | [button setBackgroundImage:image forState:UIControlStateNormal]; 17 | [button setBackgroundImage:highImage forState:UIControlStateHighlighted]; 18 | [button setFrame:CGRectMake(0, 0, 44, 44)]; 19 | [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside]; 20 | return [[UIBarButtonItem alloc] initWithCustomView:button]; 21 | 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CCNavTab 快速搭建 IOS UI 主流框架 2 | 3 | 4 | 5 | [![Build Status](http://img.shields.io/travis/rs/CCNavTab/master.svg?style=flat)](https://travis-ci.org/rs/CCNavTab) 6 | [![Pod Version](http://img.shields.io/cocoapods/v/CCNavTab.svg?style=flat)](http://cocoadocs.org/docsets/CCNavTab/) 7 | [![Pod Platform](http://img.shields.io/cocoapods/p/CCNavTab.svg?style=flat)](http://cocoadocs.org/docsets/CCNavTab/) 8 | [![Pod License](http://img.shields.io/cocoapods/l/CCNavTab.svg?style=flat)](https://mit-license.org) 9 | [![Dependency Status](https://www.versioneye.com/objective-c/CCNavTab/3.3/badge.svg?style=flat)](https://www.versioneye.com/objective-c/CCNavTab/3.3) 10 | [![Support](https://img.shields.io/badge/support-iOS%206%2B%20-blue.svg?style=flat)](https://www.apple.com/nl/ios/)  11 | 12 | 13 | *其他框架推荐 快速自定义转场动画 14 | https://github.com/xiongcaichang/CCTransition 15 | 16 | 17 | 18 | 19 | 20 | ##安装 21 | * cocopods 22 | 23 | ``` 24 | pod 'CCNavTab' 25 | ``` 26 | 27 | * 传统使用方法 28 | 新建工程,将 Lib 文件夹拖入您的项目 29 | 30 | 31 | ##使用 32 | 33 | 1.新建主控制器 MainController 继承自 CCTabController 在 MainController 的 viewDidLoad 方法中 34 | 35 | 36 | * 可选配置 37 | 38 | ```objc 39 | 40 | /** 41 | 配置导航栏的颜色/图片 42 | 注意:当背景颜色设置时图片不生效 一般二选其一 默认为系统白色 43 | */ 44 | self.navigationBarBackgroundColor=[UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1]; 45 | 46 | //self.navigationBarBackgroundImage = [UIImage imageNamed:@"background"] ; 47 | 48 | 49 | /** 50 | 可选配置 51 | 导航栏文字颜色 Title 和 BarButtonItem 默认为黑色 52 | */ 53 | self.navigationBarTintColor = [UIColor whiteColor]; 54 | 55 | ``` 56 | 57 | 2.第二步:添加子控制器配置数组 58 | 59 | * 配置数组 VIEWCONTROLLER 除下面代码创建方式外外可从storyboard 加载 60 | 61 | 62 | ``` objc 63 | self.childControllerAndIconArr=@[ 64 | /************第一个控制器配置信息*********************/ 65 | @{ 66 | VIEWCONTROLLER : [[OneController alloc]init], //控制器对象 67 | NORMAL_ICON : @"icon_classTable", //正常状态的Icon 名称 68 | SELECTED_ICON : @"icon_classTable_selected", //选中状态的Icon 名称 69 | TITLE : @"表" //Nav和Tab的标题 70 | }, 71 | /************第二个控制器配置信息*********************/ 72 | @{ 73 | VIEWCONTROLLER : [[TwoController alloc]init], 74 | NORMAL_ICON : @"icon_me", 75 | SELECTED_ICON : @"icon_me_selected", 76 | TITLE : @"校园" 77 | }, 78 | ]; 79 | 80 | 81 | ``` 82 | 83 | 84 | 85 | * bageView 使用 和系统一样,当为 @"0" 时则隐藏 86 | 87 | ```objc 88 | 89 | self.tabBarItem.badgeValue=@"6"; 90 | 91 | ``` 92 | 93 | 94 | 95 | ### 截图 96 | 97 | 98 | Drawing 99 | 100 | 101 | -------------------------------------------------------------------------------- /demoCapture.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongcaichang/CCNavTab/d35f99c5728460d2574c7bd8a38073cfd1622ff6/demoCapture.gif --------------------------------------------------------------------------------