├── .gitignore ├── CQTopBar.podspec ├── CQTopBar.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── CQTopBar ├── 1.1.0 │ └── CQTopBar.podspec ├── 1.1.2 │ └── CQTopBar.podspec ├── 1.1.5 │ └── CQTopBar.podspec ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── main_searchbutton_normal.imageset │ │ ├── Contents.json │ │ ├── main_searchbutton_normal@2x.png │ │ └── main_searchbutton_normal@3x.png │ ├── question_query_arrow_down_default.imageset │ │ ├── Contents.json │ │ ├── question_query_arrow_down_default@2x.png │ │ └── question_query_arrow_down_default@3x.png │ ├── question_query_arrow_down_selected.imageset │ │ ├── Contents.json │ │ ├── question_query_arrow_down_selected@2x.png │ │ └── question_query_arrow_down_selected@3x.png │ └── userorder_cancelbtn_highlight.imageset │ │ ├── Contents.json │ │ ├── userorder_cancelbtn_highlight@2x.png │ │ └── userorder_cancelbtn_highlight@3x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CQTopBar │ ├── CQSegmentTitleImage.h │ ├── CQSegmentTitleImage.m │ ├── CQTopBarFiltrateView.h │ ├── CQTopBarFiltrateView.m │ ├── CQTopBarSegment.h │ ├── CQTopBarSegment.m │ ├── CQTopBarSegmentCell.h │ ├── CQTopBarSegmentCell.m │ ├── CQTopBarView.h │ └── CQTopBarView.m ├── Info.plist ├── Text1.h ├── Text1.m ├── Text3.h ├── Text3.m ├── ViewController.h ├── ViewController.m ├── main.m ├── testView1.h ├── testView1.m ├── testView2.h ├── testView2.m ├── testView3.h └── testView3.m ├── CQTopBarTests ├── CQTopBarTests.m └── Info.plist ├── CQTopBarUITests ├── CQTopBarUITests.m └── Info.plist ├── README.md └── Res └── TopBar.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /CQTopBar.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "CQTopBar" 3 | s.version = "1.1.5" 4 | s.summary = "快速集成下拉菜单的小控件" 5 | s.homepage = "https://github.com/cq1402272764/CQTopBar" 6 | s.authors = {"CQ_ Develop" => "1402272764@qq.com"} 7 | s.platform = :ios, "7.0" 8 | s.license = "MIT" 9 | s.source = {:git => "git@github.com:cq1402272764/CQTopBar.git", :tag => s.version.to_s } 10 | s.source_files = "CQTopBar/CQTopBar/**/*.{h,m}" 11 | s.requires_arc = true 12 | end 13 | -------------------------------------------------------------------------------- /CQTopBar.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 42646DEC2004680500638400 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 42646DEB2004680500638400 /* AppDelegate.m */; }; 11 | 42646DEF2004680500638400 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42646DEE2004680500638400 /* ViewController.m */; }; 12 | 42646DF22004680600638400 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 42646DF02004680600638400 /* Main.storyboard */; }; 13 | 42646DF42004680600638400 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 42646DF32004680600638400 /* Assets.xcassets */; }; 14 | 42646DF72004680600638400 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 42646DF52004680600638400 /* LaunchScreen.storyboard */; }; 15 | 42646DFA2004680600638400 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 42646DF92004680600638400 /* main.m */; }; 16 | 42646E042004680800638400 /* CQTopBarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 42646E032004680800638400 /* CQTopBarTests.m */; }; 17 | 42646E0F2004680800638400 /* CQTopBarUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 42646E0E2004680800638400 /* CQTopBarUITests.m */; }; 18 | 42C44E7220196CB9007425A6 /* CQTopBarSegment.m in Sources */ = {isa = PBXBuildFile; fileRef = 42C44E6B20196CB9007425A6 /* CQTopBarSegment.m */; }; 19 | 42C44E7320196CB9007425A6 /* CQTopBarSegmentCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42C44E6D20196CB9007425A6 /* CQTopBarSegmentCell.m */; }; 20 | 42C44E7B2019B71E007425A6 /* CQSegmentTitleImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 42C44E7A2019B71E007425A6 /* CQSegmentTitleImage.m */; }; 21 | 667813142C12A0A100A6AEB8 /* CQTopBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 667813132C12A0A100A6AEB8 /* CQTopBarView.m */; }; 22 | 6678131A2C12B43800A6AEB8 /* testView1.m in Sources */ = {isa = PBXBuildFile; fileRef = 667813192C12B43800A6AEB8 /* testView1.m */; }; 23 | 6678131D2C12B44600A6AEB8 /* testView2.m in Sources */ = {isa = PBXBuildFile; fileRef = 6678131C2C12B44600A6AEB8 /* testView2.m */; }; 24 | 66E7DB0A2C119E3300BD87DD /* CQTopBarFiltrateView.m in Sources */ = {isa = PBXBuildFile; fileRef = 66E7DB082C119E3300BD87DD /* CQTopBarFiltrateView.m */; }; 25 | 66F8F2972C1845F70038DA54 /* testView3.m in Sources */ = {isa = PBXBuildFile; fileRef = 66F8F2962C1845F70038DA54 /* testView3.m */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | 42646E002004680800638400 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 42646DDF2004680500638400 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = 42646DE62004680500638400; 34 | remoteInfo = CQTopBar; 35 | }; 36 | 42646E0B2004680800638400 /* PBXContainerItemProxy */ = { 37 | isa = PBXContainerItemProxy; 38 | containerPortal = 42646DDF2004680500638400 /* Project object */; 39 | proxyType = 1; 40 | remoteGlobalIDString = 42646DE62004680500638400; 41 | remoteInfo = CQTopBar; 42 | }; 43 | /* End PBXContainerItemProxy section */ 44 | 45 | /* Begin PBXFileReference section */ 46 | 42646DE72004680500638400 /* CQTopBar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CQTopBar.app; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | 42646DEA2004680500638400 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 48 | 42646DEB2004680500638400 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 49 | 42646DED2004680500638400 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 50 | 42646DEE2004680500638400 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 51 | 42646DF12004680600638400 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 52 | 42646DF32004680600638400 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 53 | 42646DF62004680600638400 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 54 | 42646DF82004680600638400 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 42646DF92004680600638400 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 56 | 42646DFF2004680800638400 /* CQTopBarTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CQTopBarTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | 42646E032004680800638400 /* CQTopBarTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CQTopBarTests.m; sourceTree = ""; }; 58 | 42646E052004680800638400 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | 42646E0A2004680800638400 /* CQTopBarUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CQTopBarUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 60 | 42646E0E2004680800638400 /* CQTopBarUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CQTopBarUITests.m; sourceTree = ""; }; 61 | 42646E102004680800638400 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 62 | 42C44E6A20196CB9007425A6 /* CQTopBarSegment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CQTopBarSegment.h; sourceTree = ""; }; 63 | 42C44E6B20196CB9007425A6 /* CQTopBarSegment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CQTopBarSegment.m; sourceTree = ""; }; 64 | 42C44E6C20196CB9007425A6 /* CQTopBarSegmentCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CQTopBarSegmentCell.h; sourceTree = ""; }; 65 | 42C44E6D20196CB9007425A6 /* CQTopBarSegmentCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CQTopBarSegmentCell.m; sourceTree = ""; }; 66 | 42C44E792019B71E007425A6 /* CQSegmentTitleImage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CQSegmentTitleImage.h; sourceTree = ""; }; 67 | 42C44E7A2019B71E007425A6 /* CQSegmentTitleImage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CQSegmentTitleImage.m; sourceTree = ""; }; 68 | 667813122C12A0A100A6AEB8 /* CQTopBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CQTopBarView.h; sourceTree = ""; }; 69 | 667813132C12A0A100A6AEB8 /* CQTopBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CQTopBarView.m; sourceTree = ""; }; 70 | 667813182C12B43800A6AEB8 /* testView1.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = testView1.h; sourceTree = ""; }; 71 | 667813192C12B43800A6AEB8 /* testView1.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = testView1.m; sourceTree = ""; }; 72 | 6678131B2C12B44600A6AEB8 /* testView2.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = testView2.h; sourceTree = ""; }; 73 | 6678131C2C12B44600A6AEB8 /* testView2.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = testView2.m; sourceTree = ""; }; 74 | 66E7DB082C119E3300BD87DD /* CQTopBarFiltrateView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CQTopBarFiltrateView.m; sourceTree = ""; }; 75 | 66E7DB092C119E3300BD87DD /* CQTopBarFiltrateView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CQTopBarFiltrateView.h; sourceTree = ""; }; 76 | 66F8F2952C1845F70038DA54 /* testView3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testView3.h; sourceTree = ""; }; 77 | 66F8F2962C1845F70038DA54 /* testView3.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = testView3.m; sourceTree = ""; }; 78 | /* End PBXFileReference section */ 79 | 80 | /* Begin PBXFrameworksBuildPhase section */ 81 | 42646DE42004680500638400 /* Frameworks */ = { 82 | isa = PBXFrameworksBuildPhase; 83 | buildActionMask = 2147483647; 84 | files = ( 85 | ); 86 | runOnlyForDeploymentPostprocessing = 0; 87 | }; 88 | 42646DFC2004680800638400 /* Frameworks */ = { 89 | isa = PBXFrameworksBuildPhase; 90 | buildActionMask = 2147483647; 91 | files = ( 92 | ); 93 | runOnlyForDeploymentPostprocessing = 0; 94 | }; 95 | 42646E072004680800638400 /* Frameworks */ = { 96 | isa = PBXFrameworksBuildPhase; 97 | buildActionMask = 2147483647; 98 | files = ( 99 | ); 100 | runOnlyForDeploymentPostprocessing = 0; 101 | }; 102 | /* End PBXFrameworksBuildPhase section */ 103 | 104 | /* Begin PBXGroup section */ 105 | 42646DDE2004680400638400 = { 106 | isa = PBXGroup; 107 | children = ( 108 | 42646DE92004680500638400 /* CQTopBar */, 109 | 42646E022004680800638400 /* CQTopBarTests */, 110 | 42646E0D2004680800638400 /* CQTopBarUITests */, 111 | 42646DE82004680500638400 /* Products */, 112 | ); 113 | sourceTree = ""; 114 | }; 115 | 42646DE82004680500638400 /* Products */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 42646DE72004680500638400 /* CQTopBar.app */, 119 | 42646DFF2004680800638400 /* CQTopBarTests.xctest */, 120 | 42646E0A2004680800638400 /* CQTopBarUITests.xctest */, 121 | ); 122 | name = Products; 123 | sourceTree = ""; 124 | }; 125 | 42646DE92004680500638400 /* CQTopBar */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 42C44E6920196CB9007425A6 /* CQTopBar */, 129 | 42646DEA2004680500638400 /* AppDelegate.h */, 130 | 42646DEB2004680500638400 /* AppDelegate.m */, 131 | 42646DED2004680500638400 /* ViewController.h */, 132 | 42646DEE2004680500638400 /* ViewController.m */, 133 | 667813182C12B43800A6AEB8 /* testView1.h */, 134 | 667813192C12B43800A6AEB8 /* testView1.m */, 135 | 6678131B2C12B44600A6AEB8 /* testView2.h */, 136 | 6678131C2C12B44600A6AEB8 /* testView2.m */, 137 | 66F8F2952C1845F70038DA54 /* testView3.h */, 138 | 66F8F2962C1845F70038DA54 /* testView3.m */, 139 | 42646DF02004680600638400 /* Main.storyboard */, 140 | 42646DF32004680600638400 /* Assets.xcassets */, 141 | 42646DF52004680600638400 /* LaunchScreen.storyboard */, 142 | 42646DF82004680600638400 /* Info.plist */, 143 | 42646DF92004680600638400 /* main.m */, 144 | ); 145 | path = CQTopBar; 146 | sourceTree = ""; 147 | }; 148 | 42646E022004680800638400 /* CQTopBarTests */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | 42646E032004680800638400 /* CQTopBarTests.m */, 152 | 42646E052004680800638400 /* Info.plist */, 153 | ); 154 | path = CQTopBarTests; 155 | sourceTree = ""; 156 | }; 157 | 42646E0D2004680800638400 /* CQTopBarUITests */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 42646E0E2004680800638400 /* CQTopBarUITests.m */, 161 | 42646E102004680800638400 /* Info.plist */, 162 | ); 163 | path = CQTopBarUITests; 164 | sourceTree = ""; 165 | }; 166 | 42C44E6920196CB9007425A6 /* CQTopBar */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | 667813122C12A0A100A6AEB8 /* CQTopBarView.h */, 170 | 667813132C12A0A100A6AEB8 /* CQTopBarView.m */, 171 | 42C44E6A20196CB9007425A6 /* CQTopBarSegment.h */, 172 | 42C44E6B20196CB9007425A6 /* CQTopBarSegment.m */, 173 | 42C44E6C20196CB9007425A6 /* CQTopBarSegmentCell.h */, 174 | 42C44E6D20196CB9007425A6 /* CQTopBarSegmentCell.m */, 175 | 42C44E792019B71E007425A6 /* CQSegmentTitleImage.h */, 176 | 42C44E7A2019B71E007425A6 /* CQSegmentTitleImage.m */, 177 | 66E7DB092C119E3300BD87DD /* CQTopBarFiltrateView.h */, 178 | 66E7DB082C119E3300BD87DD /* CQTopBarFiltrateView.m */, 179 | ); 180 | path = CQTopBar; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXGroup section */ 184 | 185 | /* Begin PBXNativeTarget section */ 186 | 42646DE62004680500638400 /* CQTopBar */ = { 187 | isa = PBXNativeTarget; 188 | buildConfigurationList = 42646E132004680800638400 /* Build configuration list for PBXNativeTarget "CQTopBar" */; 189 | buildPhases = ( 190 | 42646DE32004680500638400 /* Sources */, 191 | 42646DE42004680500638400 /* Frameworks */, 192 | 42646DE52004680500638400 /* Resources */, 193 | ); 194 | buildRules = ( 195 | ); 196 | dependencies = ( 197 | ); 198 | name = CQTopBar; 199 | productName = CQTopBar; 200 | productReference = 42646DE72004680500638400 /* CQTopBar.app */; 201 | productType = "com.apple.product-type.application"; 202 | }; 203 | 42646DFE2004680800638400 /* CQTopBarTests */ = { 204 | isa = PBXNativeTarget; 205 | buildConfigurationList = 42646E162004680800638400 /* Build configuration list for PBXNativeTarget "CQTopBarTests" */; 206 | buildPhases = ( 207 | 42646DFB2004680800638400 /* Sources */, 208 | 42646DFC2004680800638400 /* Frameworks */, 209 | 42646DFD2004680800638400 /* Resources */, 210 | ); 211 | buildRules = ( 212 | ); 213 | dependencies = ( 214 | 42646E012004680800638400 /* PBXTargetDependency */, 215 | ); 216 | name = CQTopBarTests; 217 | productName = CQTopBarTests; 218 | productReference = 42646DFF2004680800638400 /* CQTopBarTests.xctest */; 219 | productType = "com.apple.product-type.bundle.unit-test"; 220 | }; 221 | 42646E092004680800638400 /* CQTopBarUITests */ = { 222 | isa = PBXNativeTarget; 223 | buildConfigurationList = 42646E192004680800638400 /* Build configuration list for PBXNativeTarget "CQTopBarUITests" */; 224 | buildPhases = ( 225 | 42646E062004680800638400 /* Sources */, 226 | 42646E072004680800638400 /* Frameworks */, 227 | 42646E082004680800638400 /* Resources */, 228 | ); 229 | buildRules = ( 230 | ); 231 | dependencies = ( 232 | 42646E0C2004680800638400 /* PBXTargetDependency */, 233 | ); 234 | name = CQTopBarUITests; 235 | productName = CQTopBarUITests; 236 | productReference = 42646E0A2004680800638400 /* CQTopBarUITests.xctest */; 237 | productType = "com.apple.product-type.bundle.ui-testing"; 238 | }; 239 | /* End PBXNativeTarget section */ 240 | 241 | /* Begin PBXProject section */ 242 | 42646DDF2004680500638400 /* Project object */ = { 243 | isa = PBXProject; 244 | attributes = { 245 | LastUpgradeCheck = 0920; 246 | ORGANIZATIONNAME = CQ; 247 | TargetAttributes = { 248 | 42646DE62004680500638400 = { 249 | CreatedOnToolsVersion = 9.2; 250 | ProvisioningStyle = Automatic; 251 | SystemCapabilities = { 252 | com.apple.BackgroundModes = { 253 | enabled = 0; 254 | }; 255 | }; 256 | }; 257 | 42646DFE2004680800638400 = { 258 | CreatedOnToolsVersion = 9.2; 259 | ProvisioningStyle = Automatic; 260 | TestTargetID = 42646DE62004680500638400; 261 | }; 262 | 42646E092004680800638400 = { 263 | CreatedOnToolsVersion = 9.2; 264 | ProvisioningStyle = Automatic; 265 | TestTargetID = 42646DE62004680500638400; 266 | }; 267 | }; 268 | }; 269 | buildConfigurationList = 42646DE22004680500638400 /* Build configuration list for PBXProject "CQTopBar" */; 270 | compatibilityVersion = "Xcode 8.0"; 271 | developmentRegion = en; 272 | hasScannedForEncodings = 0; 273 | knownRegions = ( 274 | en, 275 | Base, 276 | ); 277 | mainGroup = 42646DDE2004680400638400; 278 | productRefGroup = 42646DE82004680500638400 /* Products */; 279 | projectDirPath = ""; 280 | projectRoot = ""; 281 | targets = ( 282 | 42646DE62004680500638400 /* CQTopBar */, 283 | 42646DFE2004680800638400 /* CQTopBarTests */, 284 | 42646E092004680800638400 /* CQTopBarUITests */, 285 | ); 286 | }; 287 | /* End PBXProject section */ 288 | 289 | /* Begin PBXResourcesBuildPhase section */ 290 | 42646DE52004680500638400 /* Resources */ = { 291 | isa = PBXResourcesBuildPhase; 292 | buildActionMask = 2147483647; 293 | files = ( 294 | 42646DF72004680600638400 /* LaunchScreen.storyboard in Resources */, 295 | 42646DF42004680600638400 /* Assets.xcassets in Resources */, 296 | 42646DF22004680600638400 /* Main.storyboard in Resources */, 297 | ); 298 | runOnlyForDeploymentPostprocessing = 0; 299 | }; 300 | 42646DFD2004680800638400 /* Resources */ = { 301 | isa = PBXResourcesBuildPhase; 302 | buildActionMask = 2147483647; 303 | files = ( 304 | ); 305 | runOnlyForDeploymentPostprocessing = 0; 306 | }; 307 | 42646E082004680800638400 /* Resources */ = { 308 | isa = PBXResourcesBuildPhase; 309 | buildActionMask = 2147483647; 310 | files = ( 311 | ); 312 | runOnlyForDeploymentPostprocessing = 0; 313 | }; 314 | /* End PBXResourcesBuildPhase section */ 315 | 316 | /* Begin PBXSourcesBuildPhase section */ 317 | 42646DE32004680500638400 /* Sources */ = { 318 | isa = PBXSourcesBuildPhase; 319 | buildActionMask = 2147483647; 320 | files = ( 321 | 42646DEF2004680500638400 /* ViewController.m in Sources */, 322 | 6678131D2C12B44600A6AEB8 /* testView2.m in Sources */, 323 | 66E7DB0A2C119E3300BD87DD /* CQTopBarFiltrateView.m in Sources */, 324 | 42C44E7220196CB9007425A6 /* CQTopBarSegment.m in Sources */, 325 | 42C44E7B2019B71E007425A6 /* CQSegmentTitleImage.m in Sources */, 326 | 6678131A2C12B43800A6AEB8 /* testView1.m in Sources */, 327 | 667813142C12A0A100A6AEB8 /* CQTopBarView.m in Sources */, 328 | 66F8F2972C1845F70038DA54 /* testView3.m in Sources */, 329 | 42646DFA2004680600638400 /* main.m in Sources */, 330 | 42646DEC2004680500638400 /* AppDelegate.m in Sources */, 331 | 42C44E7320196CB9007425A6 /* CQTopBarSegmentCell.m in Sources */, 332 | ); 333 | runOnlyForDeploymentPostprocessing = 0; 334 | }; 335 | 42646DFB2004680800638400 /* Sources */ = { 336 | isa = PBXSourcesBuildPhase; 337 | buildActionMask = 2147483647; 338 | files = ( 339 | 42646E042004680800638400 /* CQTopBarTests.m in Sources */, 340 | ); 341 | runOnlyForDeploymentPostprocessing = 0; 342 | }; 343 | 42646E062004680800638400 /* Sources */ = { 344 | isa = PBXSourcesBuildPhase; 345 | buildActionMask = 2147483647; 346 | files = ( 347 | 42646E0F2004680800638400 /* CQTopBarUITests.m in Sources */, 348 | ); 349 | runOnlyForDeploymentPostprocessing = 0; 350 | }; 351 | /* End PBXSourcesBuildPhase section */ 352 | 353 | /* Begin PBXTargetDependency section */ 354 | 42646E012004680800638400 /* PBXTargetDependency */ = { 355 | isa = PBXTargetDependency; 356 | target = 42646DE62004680500638400 /* CQTopBar */; 357 | targetProxy = 42646E002004680800638400 /* PBXContainerItemProxy */; 358 | }; 359 | 42646E0C2004680800638400 /* PBXTargetDependency */ = { 360 | isa = PBXTargetDependency; 361 | target = 42646DE62004680500638400 /* CQTopBar */; 362 | targetProxy = 42646E0B2004680800638400 /* PBXContainerItemProxy */; 363 | }; 364 | /* End PBXTargetDependency section */ 365 | 366 | /* Begin PBXVariantGroup section */ 367 | 42646DF02004680600638400 /* Main.storyboard */ = { 368 | isa = PBXVariantGroup; 369 | children = ( 370 | 42646DF12004680600638400 /* Base */, 371 | ); 372 | name = Main.storyboard; 373 | sourceTree = ""; 374 | }; 375 | 42646DF52004680600638400 /* LaunchScreen.storyboard */ = { 376 | isa = PBXVariantGroup; 377 | children = ( 378 | 42646DF62004680600638400 /* Base */, 379 | ); 380 | name = LaunchScreen.storyboard; 381 | sourceTree = ""; 382 | }; 383 | /* End PBXVariantGroup section */ 384 | 385 | /* Begin XCBuildConfiguration section */ 386 | 42646E112004680800638400 /* Debug */ = { 387 | isa = XCBuildConfiguration; 388 | buildSettings = { 389 | ALWAYS_SEARCH_USER_PATHS = NO; 390 | CLANG_ANALYZER_NONNULL = YES; 391 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 392 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 393 | CLANG_CXX_LIBRARY = "libc++"; 394 | CLANG_ENABLE_MODULES = YES; 395 | CLANG_ENABLE_OBJC_ARC = YES; 396 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 397 | CLANG_WARN_BOOL_CONVERSION = YES; 398 | CLANG_WARN_COMMA = YES; 399 | CLANG_WARN_CONSTANT_CONVERSION = YES; 400 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 401 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 402 | CLANG_WARN_EMPTY_BODY = YES; 403 | CLANG_WARN_ENUM_CONVERSION = YES; 404 | CLANG_WARN_INFINITE_RECURSION = YES; 405 | CLANG_WARN_INT_CONVERSION = YES; 406 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 407 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 408 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 409 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 410 | CLANG_WARN_STRICT_PROTOTYPES = YES; 411 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 412 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 413 | CLANG_WARN_UNREACHABLE_CODE = YES; 414 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 415 | CODE_SIGN_IDENTITY = "iPhone Developer"; 416 | COPY_PHASE_STRIP = NO; 417 | DEBUG_INFORMATION_FORMAT = dwarf; 418 | ENABLE_STRICT_OBJC_MSGSEND = YES; 419 | ENABLE_TESTABILITY = YES; 420 | GCC_C_LANGUAGE_STANDARD = gnu11; 421 | GCC_DYNAMIC_NO_PIC = NO; 422 | GCC_NO_COMMON_BLOCKS = YES; 423 | GCC_OPTIMIZATION_LEVEL = 0; 424 | GCC_PREPROCESSOR_DEFINITIONS = ( 425 | "DEBUG=1", 426 | "$(inherited)", 427 | ); 428 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 429 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 430 | GCC_WARN_UNDECLARED_SELECTOR = YES; 431 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 432 | GCC_WARN_UNUSED_FUNCTION = YES; 433 | GCC_WARN_UNUSED_VARIABLE = YES; 434 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 435 | MTL_ENABLE_DEBUG_INFO = YES; 436 | ONLY_ACTIVE_ARCH = YES; 437 | SDKROOT = iphoneos; 438 | }; 439 | name = Debug; 440 | }; 441 | 42646E122004680800638400 /* Release */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | ALWAYS_SEARCH_USER_PATHS = NO; 445 | CLANG_ANALYZER_NONNULL = YES; 446 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 447 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 448 | CLANG_CXX_LIBRARY = "libc++"; 449 | CLANG_ENABLE_MODULES = YES; 450 | CLANG_ENABLE_OBJC_ARC = YES; 451 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 452 | CLANG_WARN_BOOL_CONVERSION = YES; 453 | CLANG_WARN_COMMA = YES; 454 | CLANG_WARN_CONSTANT_CONVERSION = YES; 455 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 456 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 457 | CLANG_WARN_EMPTY_BODY = YES; 458 | CLANG_WARN_ENUM_CONVERSION = YES; 459 | CLANG_WARN_INFINITE_RECURSION = YES; 460 | CLANG_WARN_INT_CONVERSION = YES; 461 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 462 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 463 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 464 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 465 | CLANG_WARN_STRICT_PROTOTYPES = YES; 466 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 467 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 468 | CLANG_WARN_UNREACHABLE_CODE = YES; 469 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 470 | CODE_SIGN_IDENTITY = "iPhone Developer"; 471 | COPY_PHASE_STRIP = NO; 472 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 473 | ENABLE_NS_ASSERTIONS = NO; 474 | ENABLE_STRICT_OBJC_MSGSEND = YES; 475 | GCC_C_LANGUAGE_STANDARD = gnu11; 476 | GCC_NO_COMMON_BLOCKS = YES; 477 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 478 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 479 | GCC_WARN_UNDECLARED_SELECTOR = YES; 480 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 481 | GCC_WARN_UNUSED_FUNCTION = YES; 482 | GCC_WARN_UNUSED_VARIABLE = YES; 483 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 484 | MTL_ENABLE_DEBUG_INFO = NO; 485 | SDKROOT = iphoneos; 486 | VALIDATE_PRODUCT = YES; 487 | }; 488 | name = Release; 489 | }; 490 | 42646E142004680800638400 /* Debug */ = { 491 | isa = XCBuildConfiguration; 492 | buildSettings = { 493 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 494 | CODE_SIGN_IDENTITY = "Apple Development"; 495 | CODE_SIGN_STYLE = Automatic; 496 | DEVELOPMENT_TEAM = QAVZJBHY82; 497 | INFOPLIST_FILE = CQTopBar/Info.plist; 498 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 499 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 500 | PRODUCT_BUNDLE_IDENTIFIER = com.DevApp.CQTopBar; 501 | PRODUCT_NAME = "$(TARGET_NAME)"; 502 | PROVISIONING_PROFILE_SPECIFIER = ""; 503 | TARGETED_DEVICE_FAMILY = "1,2"; 504 | }; 505 | name = Debug; 506 | }; 507 | 42646E152004680800638400 /* Release */ = { 508 | isa = XCBuildConfiguration; 509 | buildSettings = { 510 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 511 | CODE_SIGN_IDENTITY = "Apple Development"; 512 | CODE_SIGN_STYLE = Automatic; 513 | DEVELOPMENT_TEAM = QAVZJBHY82; 514 | INFOPLIST_FILE = CQTopBar/Info.plist; 515 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 516 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 517 | PRODUCT_BUNDLE_IDENTIFIER = com.DevApp.CQTopBar; 518 | PRODUCT_NAME = "$(TARGET_NAME)"; 519 | PROVISIONING_PROFILE_SPECIFIER = ""; 520 | TARGETED_DEVICE_FAMILY = "1,2"; 521 | }; 522 | name = Release; 523 | }; 524 | 42646E172004680800638400 /* Debug */ = { 525 | isa = XCBuildConfiguration; 526 | buildSettings = { 527 | BUNDLE_LOADER = "$(TEST_HOST)"; 528 | CODE_SIGN_STYLE = Automatic; 529 | INFOPLIST_FILE = CQTopBarTests/Info.plist; 530 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 531 | PRODUCT_BUNDLE_IDENTIFIER = com.appDev.MrFay.CQTopBarTests; 532 | PRODUCT_NAME = "$(TARGET_NAME)"; 533 | TARGETED_DEVICE_FAMILY = "1,2"; 534 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CQTopBar.app/CQTopBar"; 535 | }; 536 | name = Debug; 537 | }; 538 | 42646E182004680800638400 /* Release */ = { 539 | isa = XCBuildConfiguration; 540 | buildSettings = { 541 | BUNDLE_LOADER = "$(TEST_HOST)"; 542 | CODE_SIGN_STYLE = Automatic; 543 | INFOPLIST_FILE = CQTopBarTests/Info.plist; 544 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 545 | PRODUCT_BUNDLE_IDENTIFIER = com.appDev.MrFay.CQTopBarTests; 546 | PRODUCT_NAME = "$(TARGET_NAME)"; 547 | TARGETED_DEVICE_FAMILY = "1,2"; 548 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CQTopBar.app/CQTopBar"; 549 | }; 550 | name = Release; 551 | }; 552 | 42646E1A2004680800638400 /* Debug */ = { 553 | isa = XCBuildConfiguration; 554 | buildSettings = { 555 | CODE_SIGN_STYLE = Automatic; 556 | INFOPLIST_FILE = CQTopBarUITests/Info.plist; 557 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 558 | PRODUCT_BUNDLE_IDENTIFIER = com.appDev.MrFay.CQTopBarUITests; 559 | PRODUCT_NAME = "$(TARGET_NAME)"; 560 | TARGETED_DEVICE_FAMILY = "1,2"; 561 | TEST_TARGET_NAME = CQTopBar; 562 | }; 563 | name = Debug; 564 | }; 565 | 42646E1B2004680800638400 /* Release */ = { 566 | isa = XCBuildConfiguration; 567 | buildSettings = { 568 | CODE_SIGN_STYLE = Automatic; 569 | INFOPLIST_FILE = CQTopBarUITests/Info.plist; 570 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 571 | PRODUCT_BUNDLE_IDENTIFIER = com.appDev.MrFay.CQTopBarUITests; 572 | PRODUCT_NAME = "$(TARGET_NAME)"; 573 | TARGETED_DEVICE_FAMILY = "1,2"; 574 | TEST_TARGET_NAME = CQTopBar; 575 | }; 576 | name = Release; 577 | }; 578 | /* End XCBuildConfiguration section */ 579 | 580 | /* Begin XCConfigurationList section */ 581 | 42646DE22004680500638400 /* Build configuration list for PBXProject "CQTopBar" */ = { 582 | isa = XCConfigurationList; 583 | buildConfigurations = ( 584 | 42646E112004680800638400 /* Debug */, 585 | 42646E122004680800638400 /* Release */, 586 | ); 587 | defaultConfigurationIsVisible = 0; 588 | defaultConfigurationName = Release; 589 | }; 590 | 42646E132004680800638400 /* Build configuration list for PBXNativeTarget "CQTopBar" */ = { 591 | isa = XCConfigurationList; 592 | buildConfigurations = ( 593 | 42646E142004680800638400 /* Debug */, 594 | 42646E152004680800638400 /* Release */, 595 | ); 596 | defaultConfigurationIsVisible = 0; 597 | defaultConfigurationName = Release; 598 | }; 599 | 42646E162004680800638400 /* Build configuration list for PBXNativeTarget "CQTopBarTests" */ = { 600 | isa = XCConfigurationList; 601 | buildConfigurations = ( 602 | 42646E172004680800638400 /* Debug */, 603 | 42646E182004680800638400 /* Release */, 604 | ); 605 | defaultConfigurationIsVisible = 0; 606 | defaultConfigurationName = Release; 607 | }; 608 | 42646E192004680800638400 /* Build configuration list for PBXNativeTarget "CQTopBarUITests" */ = { 609 | isa = XCConfigurationList; 610 | buildConfigurations = ( 611 | 42646E1A2004680800638400 /* Debug */, 612 | 42646E1B2004680800638400 /* Release */, 613 | ); 614 | defaultConfigurationIsVisible = 0; 615 | defaultConfigurationName = Release; 616 | }; 617 | /* End XCConfigurationList section */ 618 | }; 619 | rootObject = 42646DDF2004680500638400 /* Project object */; 620 | } 621 | -------------------------------------------------------------------------------- /CQTopBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CQTopBar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CQTopBar/1.1.0/CQTopBar.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "CQTopBar" 3 | s.version = "1.1.0" 4 | s.summary = "快速集成下拉菜单的小控件" 5 | s.homepage = "https://github.com/cq1402272764/CQTopBar" 6 | s.authors = {"CQ_ Develop" => "1402272764@qq.com"} 7 | s.platform = :ios, "7.0" 8 | s.license = "MIT" 9 | s.source = {:git => "https://github.com/cq1402272764/CQTopBar.git", :tag => s.version.to_s } 10 | s.source_files = "CQTopBar/CQTopBar/**/*.{h,m}" 11 | s.requires_arc = true 12 | end 13 | -------------------------------------------------------------------------------- /CQTopBar/1.1.2/CQTopBar.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "CQTopBar" 3 | s.version = "1.1.2" 4 | s.summary = "快速集成下拉菜单的小控件" 5 | s.homepage = "https://github.com/cq1402272764/CQTopBar" 6 | s.authors = {"CQ_ Develop" => "1402272764@qq.com"} 7 | s.platform = :ios, "7.0" 8 | s.license = "MIT" 9 | s.source = {:git => "https://github.com/cq1402272764/CQTopBar.git", :tag => s.version.to_s } 10 | s.source_files = "CQTopBar/CQTopBar/**/*.{h,m}" 11 | s.requires_arc = true 12 | end 13 | -------------------------------------------------------------------------------- /CQTopBar/1.1.5/CQTopBar.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "CQTopBar" 3 | s.version = "1.1.5" 4 | s.summary = "快速集成下拉菜单的小控件" 5 | s.homepage = "https://github.com/cq1402272764/CQTopBar" 6 | s.authors = {"CQ_ Develop" => "1402272764@qq.com"} 7 | s.platform = :ios, "7.0" 8 | s.license = "MIT" 9 | s.source = {:git => "git@github.com:cq1402272764/CQTopBar.git", :tag => s.version.to_s } 10 | s.source_files = "CQTopBar/CQTopBar/**/*.{h,m}" 11 | s.requires_arc = true 12 | end 13 | -------------------------------------------------------------------------------- /CQTopBar/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/9. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /CQTopBar/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/9. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/main_searchbutton_normal.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "main_searchbutton_normal@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "main_searchbutton_normal@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/main_searchbutton_normal.imageset/main_searchbutton_normal@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cq1402272764/CQTopBar/eb27ed25e0a35f78365c51056b434472a0469d4c/CQTopBar/Assets.xcassets/main_searchbutton_normal.imageset/main_searchbutton_normal@2x.png -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/main_searchbutton_normal.imageset/main_searchbutton_normal@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cq1402272764/CQTopBar/eb27ed25e0a35f78365c51056b434472a0469d4c/CQTopBar/Assets.xcassets/main_searchbutton_normal.imageset/main_searchbutton_normal@3x.png -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/question_query_arrow_down_default.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "question_query_arrow_down_default@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "question_query_arrow_down_default@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/question_query_arrow_down_default.imageset/question_query_arrow_down_default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cq1402272764/CQTopBar/eb27ed25e0a35f78365c51056b434472a0469d4c/CQTopBar/Assets.xcassets/question_query_arrow_down_default.imageset/question_query_arrow_down_default@2x.png -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/question_query_arrow_down_default.imageset/question_query_arrow_down_default@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cq1402272764/CQTopBar/eb27ed25e0a35f78365c51056b434472a0469d4c/CQTopBar/Assets.xcassets/question_query_arrow_down_default.imageset/question_query_arrow_down_default@3x.png -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/question_query_arrow_down_selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "question_query_arrow_down_selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "question_query_arrow_down_selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/question_query_arrow_down_selected.imageset/question_query_arrow_down_selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cq1402272764/CQTopBar/eb27ed25e0a35f78365c51056b434472a0469d4c/CQTopBar/Assets.xcassets/question_query_arrow_down_selected.imageset/question_query_arrow_down_selected@2x.png -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/question_query_arrow_down_selected.imageset/question_query_arrow_down_selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cq1402272764/CQTopBar/eb27ed25e0a35f78365c51056b434472a0469d4c/CQTopBar/Assets.xcassets/question_query_arrow_down_selected.imageset/question_query_arrow_down_selected@3x.png -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/userorder_cancelbtn_highlight.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "userorder_cancelbtn_highlight@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "userorder_cancelbtn_highlight@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/userorder_cancelbtn_highlight.imageset/userorder_cancelbtn_highlight@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cq1402272764/CQTopBar/eb27ed25e0a35f78365c51056b434472a0469d4c/CQTopBar/Assets.xcassets/userorder_cancelbtn_highlight.imageset/userorder_cancelbtn_highlight@2x.png -------------------------------------------------------------------------------- /CQTopBar/Assets.xcassets/userorder_cancelbtn_highlight.imageset/userorder_cancelbtn_highlight@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cq1402272764/CQTopBar/eb27ed25e0a35f78365c51056b434472a0469d4c/CQTopBar/Assets.xcassets/userorder_cancelbtn_highlight.imageset/userorder_cancelbtn_highlight@3x.png -------------------------------------------------------------------------------- /CQTopBar/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 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /CQTopBar/Base.lproj/Main.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 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /CQTopBar/CQTopBar/CQSegmentTitleImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // CQSegmentTitleImage.h 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/25. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CQSegmentTitleImage : UIButton 12 | @property (nonatomic, strong) UIFont *segmentTitleFont; 13 | + (instancetype)segmentTitleImageButtons; 14 | @end 15 | -------------------------------------------------------------------------------- /CQTopBar/CQTopBar/CQSegmentTitleImage.m: -------------------------------------------------------------------------------- 1 | // 2 | // CQSegmentTitleImage.m 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/25. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import "CQSegmentTitleImage.h" 10 | 11 | @implementation CQSegmentTitleImage 12 | 13 | const CGFloat space = 5; 14 | const CGFloat spaceX = 3; 15 | 16 | + (instancetype)segmentTitleImageButtons{ 17 | return [[self alloc] init]; 18 | } 19 | 20 | - (id)initWithFrame:(CGRect)frame{ 21 | self = [super initWithFrame:frame]; 22 | if (self) { 23 | self.adjustsImageWhenHighlighted = NO; 24 | self.imageView.contentMode = UIViewContentModeLeft; 25 | self.titleLabel.textAlignment = NSTextAlignmentCenter; 26 | } 27 | return self; 28 | } 29 | 30 | - (CGRect)titleRectForContentRect:(CGRect)contentRect{ 31 | CGFloat titleX = [self gapWithWidth:contentRect]/2+spaceX; 32 | CGFloat titleY = 0; 33 | CGFloat titleW = [self titleWithWidth:contentRect.size.width]; 34 | CGFloat titleH = contentRect.size.height; 35 | return CGRectMake(titleX, titleY, titleW, titleH); 36 | } 37 | 38 | - (CGRect)imageRectForContentRect:(CGRect)contentRect{ 39 | UIImage *image = [self imageForState:UIControlStateNormal]; 40 | CGFloat imageX = [self gapWithWidth:contentRect]/2+[self titleWithWidth:contentRect.size.width]+space+spaceX; 41 | CGFloat imageY = 0; 42 | CGFloat imageW = image.size.width; 43 | CGFloat imageH = contentRect.size.height; 44 | return CGRectMake(imageX, imageY, imageW, imageH); 45 | } 46 | 47 | - (CGFloat)gapWithWidth:(CGRect)contentRect{ 48 | UIImage *image = [self imageForState:UIControlStateNormal]; 49 | return contentRect.size.width-([self titleWithWidth:contentRect.size.width]+image.size.width+space)-spaceX*2; 50 | } 51 | 52 | - (CGFloat)titleWithWidth:(CGFloat)width{ 53 | UIImage *image = [self imageForState:UIControlStateNormal]; 54 | NSString *title = [self titleForState:UIControlStateNormal]; 55 | CGSize size = CGSizeMake(width, MAXFLOAT); 56 | self.segmentTitleFont = self.segmentTitleFont==nil?[UIFont systemFontOfSize:13]:self.segmentTitleFont; 57 | CGFloat titleW = [title boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:self.segmentTitleFont} context:nil].size.width; 58 | if (titleW+space+image.size.width+spaceX*2>width) titleW = width - space -image.size.width-spaceX*2; 59 | return titleW; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /CQTopBar/CQTopBar/CQTopBarFiltrateView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CQTopBarFiltrateView.h 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/9. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CQTopBarFiltrateView; 11 | @protocol CQTopBarFiltrateViewDelegate 12 | @optional 13 | - (void)topBarWithBarView:(CQTopBarFiltrateView *)topBar indexPath:(NSIndexPath *)indexPath; 14 | @end 15 | @interface CQTopBarFiltrateView : UIView 16 | @property (nonatomic, weak) id delegate; 17 | @property (nonatomic, strong) UICollectionView * topBarCollectionView; 18 | @property (nonatomic, strong) NSArray * pageView; 19 | - (instancetype)initWithFrame:(CGRect)frame pageViews:(NSArray *)pageViews; 20 | @end 21 | -------------------------------------------------------------------------------- /CQTopBar/CQTopBar/CQTopBarFiltrateView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CQTopBarFiltrateView.m 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/9. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import "CQTopBarFiltrateView.h" 10 | 11 | #define KScreenHeight [[UIScreen mainScreen] bounds].size.height 12 | 13 | @interface CQTopBarFiltrateView() 14 | 15 | @end 16 | 17 | @implementation CQTopBarFiltrateView 18 | 19 | static NSString *ID = @"CQTopBarFiltrateViewCell"; 20 | 21 | - (NSArray *)pageView{ 22 | if (!_pageView) { 23 | _pageView = [NSArray array]; 24 | } 25 | return _pageView; 26 | } 27 | 28 | - (instancetype)initWithFrame:(CGRect)frame pageViews:(NSArray *)pageViews{ 29 | self = [super initWithFrame:frame]; 30 | if (self) { 31 | if (pageViews.count != 0) { 32 | [self initUIWithFrame:frame pageViews:pageViews]; 33 | } 34 | } 35 | return self; 36 | } 37 | 38 | - (void)setFrame:(CGRect)frame{ 39 | [super setFrame:frame]; 40 | if (self.topBarCollectionView != nil){ 41 | UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.topBarCollectionView.collectionViewLayout; 42 | layout.itemSize = CGSizeMake(frame.size.width, frame.size.height); 43 | self.topBarCollectionView.collectionViewLayout = layout; 44 | self.topBarCollectionView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height); 45 | } 46 | } 47 | 48 | - (void)initUIWithFrame:(CGRect)frame pageViews:(NSArray *)pageViews{ 49 | UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; 50 | layout.itemSize = CGSizeMake(frame.size.width, frame.size.height); 51 | layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; 52 | self.topBarCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height) collectionViewLayout:layout]; 53 | self.topBarCollectionView.dataSource = self; 54 | self.topBarCollectionView.delegate = self; 55 | self.topBarCollectionView.scrollEnabled = NO; 56 | self.topBarCollectionView.showsHorizontalScrollIndicator = NO; 57 | self.topBarCollectionView.clipsToBounds = YES; 58 | [self addSubview:self.topBarCollectionView]; 59 | self.topBarCollectionView.backgroundColor = [UIColor clearColor]; 60 | [self.topBarCollectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:ID]; 61 | self.pageView = pageViews; 62 | } 63 | 64 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ 65 | return self.pageView.count; 66 | } 67 | 68 | - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 69 | UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath]; 70 | [cell.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; 71 | UIView *contentView = self.pageView[indexPath.row]; 72 | [UIView animateKeyframesWithDuration:0.3 delay:0 options:UIViewKeyframeAnimationOptionCalculationModePaced animations:^{ 73 | contentView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); 74 | [cell.contentView addSubview:contentView]; 75 | } completion:nil]; 76 | cell.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3]; 77 | return cell; 78 | } 79 | 80 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ 81 | if ([_delegate respondsToSelector:@selector(topBarWithBarView:indexPath:)]) { 82 | [_delegate topBarWithBarView:self indexPath:indexPath]; 83 | } 84 | } 85 | 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /CQTopBar/CQTopBar/CQTopBarSegment.h: -------------------------------------------------------------------------------- 1 | // 2 | // CQTopBarSegment.h 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/10. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class CQTopBarSegment,CQTopBarFiltrateView; 12 | @protocol CQTopBarSegmentDelegate 13 | @optional 14 | - (void)topBarSegmentWithBlock:(CQTopBarSegment *_Nonnull)segment indexPath:(NSIndexPath *_Nonnull)indexPath; 15 | - (void)topBarSegmentWithSegmentView:(CQTopBarSegment *_Nonnull)segmentView; 16 | @end 17 | 18 | @interface CQTopBarSegment : UIView 19 | @property (nonatomic, weak) id _Nullable delegate; 20 | @property (nonatomic, strong) UICollectionView * _Nonnull collectionView; 21 | @property (nonatomic, strong) NSMutableArray * _Nonnull sectionTitles; 22 | @property (nonatomic, strong) UIColor * _Nonnull titleTextColor UI_APPEARANCE_SELECTOR; 23 | @property (nonatomic, strong) UIColor * _Nonnull selectedTitleTextColor UI_APPEARANCE_SELECTOR; 24 | @property (nonatomic, strong) UIFont * _Nonnull titleTextFont; 25 | @property (nonatomic, copy) NSString * _Nullable segmentImage; 26 | @property (nonatomic, copy) NSString * _Nonnull selectSegmentImage; 27 | @property (nonatomic, strong) UIColor * _Nonnull segmentlineColor; 28 | @property (nonatomic, strong) UIColor * _Nonnull segmentbackColor; 29 | @property (nonatomic, strong) UIColor * _Nonnull selectSegmentbackColor; 30 | @property (nonatomic, strong) UIImage * _Nullable segmentbackImage; 31 | @property (nonatomic, strong) UIImage * _Nullable selectSegmentbackImage; 32 | 33 | - (instancetype _Nonnull )initWithFrame:(CGRect)frame sectionTitles:(NSArray *_Nonnull)sectionTitles; 34 | - (void)topBarReplaceObjectsAtIndexes:(NSUInteger)indexes withObjects:(id _Nonnull )objects BarView:(CQTopBarFiltrateView *_Nonnull)barView; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /CQTopBar/CQTopBar/CQTopBarSegment.m: -------------------------------------------------------------------------------- 1 | // 2 | // CQTopBarSegment.m 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/10. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import "CQTopBarSegment.h" 10 | #import "CQTopBarSegmentCell.h" 11 | #import "CQTopBarFiltrateView.h" 12 | 13 | @interface CQTopBarSegment () 14 | @end 15 | 16 | @implementation CQTopBarSegment 17 | 18 | static NSString *ID = @"CQTopBarSegmentCell"; 19 | const NSUInteger defaultTextSize = 13; 20 | 21 | - (instancetype)initWithFrame:(CGRect)frame sectionTitles:(NSArray *)sectionTitles{ 22 | self = [super initWithFrame:frame]; 23 | if (self) { 24 | CGRect rect = frame; 25 | rect.origin.y = 0; 26 | frame = rect; 27 | if (sectionTitles.count != 0) { 28 | [self initUIWithFrame:frame sectionTitles:sectionTitles]; 29 | } 30 | } 31 | return self; 32 | } 33 | 34 | - (void)initUIWithFrame:(CGRect)frame sectionTitles:(NSArray *)sectionTitles{ 35 | self.sectionTitles = [NSMutableArray arrayWithArray:sectionTitles]; 36 | UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; 37 | layout.minimumInteritemSpacing = 0; 38 | layout.minimumLineSpacing = 0; 39 | layout.itemSize = CGSizeMake(frame.size.width/_sectionTitles.count, frame.size.height); 40 | layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; 41 | self.collectionView = [[UICollectionView alloc] initWithFrame:frame collectionViewLayout:layout]; 42 | self.collectionView.dataSource = self; 43 | self.collectionView.delegate = self; 44 | self.collectionView.scrollEnabled = NO; 45 | self.collectionView.showsHorizontalScrollIndicator = NO; 46 | self.collectionView.backgroundColor = [UIColor whiteColor]; 47 | [self addSubview:self.collectionView]; 48 | [self.collectionView registerClass:[CQTopBarSegmentCell class] forCellWithReuseIdentifier:ID]; 49 | } 50 | 51 | - (void)topBarReplaceObjectsAtIndexes:(NSUInteger)indexes withObjects:(id)objects BarView:(CQTopBarFiltrateView *)barView{ 52 | [self.sectionTitles replaceObjectAtIndex:indexes withObject:objects]; 53 | [UIView animateKeyframesWithDuration:0.3 delay:0 options:UIViewKeyframeAnimationOptionCalculationModePaced animations:^{ 54 | CGRect rect = barView.frame; 55 | rect.size.height = 0; 56 | barView.frame = rect; 57 | } completion:nil]; 58 | [self.collectionView reloadData]; 59 | } 60 | 61 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ 62 | return self.sectionTitles.count; 63 | } 64 | 65 | - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 66 | CQTopBarSegmentCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath]; 67 | cell.index = indexPath.row; 68 | cell.count = self.sectionTitles.count; 69 | NSString *title = self.sectionTitles[indexPath.row]; 70 | [cell.titleImage setTitle:title forState:UIControlStateNormal]; 71 | cell.titleImage.titleLabel.font = self.titleTextFont==nil?[UIFont systemFontOfSize:defaultTextSize]:self.titleTextFont; 72 | cell.titleImage.segmentTitleFont = cell.titleImage.titleLabel.font; 73 | [cell.titleImage setTitleColor:self.titleTextColor==nil?[UIColor blackColor]:self.titleTextColor forState:UIControlStateNormal]; 74 | cell.segmentBtn.hidden = YES; 75 | cell.crossLine.backgroundColor = self.segmentlineColor == nil ? [UIColor grayColor] : self.segmentlineColor; 76 | cell.line.backgroundColor = self.segmentlineColor == nil ? [UIColor grayColor] : self.segmentlineColor; 77 | [cell.titleImage setImage:[UIImage imageNamed:self.segmentImage==nil?@"":self.segmentImage] forState:UIControlStateNormal]; 78 | cell.backgroundColor = self.segmentbackColor == nil?[UIColor whiteColor]:self.segmentbackColor; 79 | cell.backImageView.image = self.segmentbackImage; 80 | [cell.segmentBtn setBackgroundImage:self.selectSegmentbackImage forState:UIControlStateNormal]; 81 | if (indexPath.row==self.sectionTitles.count-1) { 82 | cell.line.hidden = YES; 83 | }else{ 84 | cell.line.hidden = NO; 85 | } 86 | cell.delegate = self; 87 | return cell; 88 | } 89 | 90 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ 91 | CQTopBarSegmentCell *cell = (CQTopBarSegmentCell *)[collectionView cellForItemAtIndexPath:indexPath]; 92 | cell.selected = YES; 93 | cell.segmentBtn.hidden = !cell.selected; 94 | [cell.titleImage setTitleColor:self.selectedTitleTextColor == nil?[UIColor redColor]:self.selectedTitleTextColor forState:UIControlStateNormal]; 95 | cell.backgroundColor = self.selectSegmentbackColor == nil?[UIColor whiteColor]:self.selectSegmentbackColor; 96 | 97 | if ([_delegate respondsToSelector:@selector(topBarSegmentWithBlock:indexPath:)]) { 98 | [_delegate topBarSegmentWithBlock:self indexPath:indexPath]; 99 | } 100 | [cell.titleImage setImage:[UIImage imageNamed:self.selectSegmentImage==nil?@"":self.selectSegmentImage] forState:UIControlStateNormal]; 101 | } 102 | 103 | - (void)topBarSegmentCellWithBlock:(CQTopBarSegmentCell *)topBar{ 104 | topBar.segmentBtn.hidden = YES; 105 | if ([_delegate respondsToSelector:@selector(topBarSegmentWithSegmentView:)]) { 106 | [_delegate topBarSegmentWithSegmentView:self]; 107 | } 108 | [self setupCellAttribute:topBar]; 109 | } 110 | 111 | - (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath{ 112 | CQTopBarSegmentCell *cell = (CQTopBarSegmentCell *)[collectionView cellForItemAtIndexPath:indexPath]; 113 | cell.selected = NO; 114 | cell.segmentBtn.hidden = !cell.selected; 115 | [self setupCellAttribute:cell]; 116 | } 117 | 118 | - (void)setupCellAttribute:(CQTopBarSegmentCell *)cell{ 119 | [cell.titleImage setImage:[UIImage imageNamed:self.segmentImage==nil?@"":self.segmentImage] forState:UIControlStateNormal]; 120 | [cell.titleImage setTitleColor:self.titleTextColor==nil?[UIColor blackColor]:self.titleTextColor forState:UIControlStateNormal]; 121 | cell.backgroundColor = self.segmentbackColor == nil?[UIColor whiteColor]:self.segmentbackColor; 122 | } 123 | 124 | @end 125 | -------------------------------------------------------------------------------- /CQTopBar/CQTopBar/CQTopBarSegmentCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // CQTopBarSegmentCell.h 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/10. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CQSegmentTitleImage.h" 11 | 12 | @class CQTopBarSegmentCell; 13 | @protocol CQTopBarSegmentCellDelegate 14 | @optional 15 | - (void)topBarSegmentCellWithBlock:(CQTopBarSegmentCell *)topBar; 16 | @end 17 | @interface CQTopBarSegmentCell : UICollectionViewCell 18 | @property (nonatomic, weak) iddelegate; 19 | @property (nonatomic, strong) UIButton * segmentBtn; 20 | @property (nonatomic, strong) CQSegmentTitleImage *titleImage; 21 | @property (nonatomic, strong) UIView *line; 22 | @property (nonatomic, strong) UIView *crossLine; 23 | @property (nonatomic, strong) UIImageView *backImageView; 24 | @property (nonatomic, assign) NSInteger index; 25 | @property (nonatomic, assign) NSInteger count; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /CQTopBar/CQTopBar/CQTopBarSegmentCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // CQTopBarSegmentCell.m 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/10. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import "CQTopBarSegmentCell.h" 10 | #import "CQSegmentTitleImage.h" 11 | 12 | @implementation CQTopBarSegmentCell 13 | 14 | - (instancetype)initWithFrame:(CGRect)frame{ 15 | self = [super initWithFrame:frame]; 16 | if (self) { 17 | self.backImageView = [[UIImageView alloc] init]; 18 | [self.contentView addSubview:self.backImageView]; 19 | 20 | self.segmentBtn = [[UIButton alloc] init]; 21 | self.segmentBtn.hidden = YES; 22 | [self.segmentBtn addTarget:self action:@selector(segmentViewBtn) forControlEvents:UIControlEventTouchUpInside]; 23 | [self.contentView addSubview:self.segmentBtn]; 24 | 25 | self.titleImage = [[CQSegmentTitleImage alloc] init]; 26 | [self.titleImage setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; 27 | [self.contentView addSubview:self.titleImage]; 28 | self.titleImage.userInteractionEnabled = NO; 29 | 30 | self.line = [[UIView alloc] init]; 31 | [self.contentView addSubview:self.line]; 32 | self.crossLine = [[UIView alloc] init]; 33 | [self.contentView addSubview:self.crossLine]; 34 | } 35 | return self; 36 | } 37 | 38 | 39 | - (void)layoutSubviews{ 40 | [super layoutSubviews]; 41 | CGFloat lineW = 0.5; 42 | CGFloat backImageViewY = self.index==0?10:5; 43 | CGFloat spacing; 44 | if (self.index==0) { 45 | spacing = 15; 46 | }else if (self.index+1 == self.count){ 47 | spacing = 15; 48 | }else{ 49 | spacing = 10; 50 | } 51 | self.backImageView.frame = CGRectMake(backImageViewY, 5, CGRectGetWidth(self.bounds)-spacing, CGRectGetHeight(self.bounds)-10); 52 | self.line.frame = CGRectMake(CGRectGetWidth(self.bounds)-lineW, CGRectGetHeight(self.bounds)/4, lineW, CGRectGetHeight(self.bounds)/2); 53 | self.crossLine.frame = CGRectMake(0, CGRectGetHeight(self.bounds)-lineW, CGRectGetWidth(self.bounds), lineW); 54 | self.titleImage.frame = CGRectMake(0, 0, CGRectGetWidth(self.bounds)-lineW, CGRectGetHeight(self.bounds)); 55 | self.segmentBtn.frame = CGRectMake(backImageViewY, 5, CGRectGetWidth(self.bounds)-spacing, CGRectGetHeight(self.bounds)-10); 56 | } 57 | 58 | - (void)segmentViewBtn{ 59 | if ([_delegate respondsToSelector:@selector(topBarSegmentCellWithBlock:)]) { 60 | [_delegate topBarSegmentCellWithBlock:self]; 61 | } 62 | } 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /CQTopBar/CQTopBar/CQTopBarView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CQTopBarView.h 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/9. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CQTopBarView : UIView 12 | 13 | /** 14 | 初始化 15 | contentView:topBar的中间其他view显示 16 | sectionTitles:Segment文字数组 17 | pageViews:下拉出来的view数组 18 | */ 19 | - (instancetype _Nonnull)initWithFrame:(CGRect)frame 20 | ContentView:(UIView *_Nonnull)contentView 21 | SectionTitles:(NSArray *_Nonnull)sectionTitles 22 | PageViews:(NSArray *_Nonnull)pageViews; 23 | 24 | /** 25 | * 修改segment文字 26 | * indexes:需要修改第几个文字 27 | * objects:需要修改文字内容 28 | */ 29 | - (void)topBarReplaceObjectsAtIndexes:(NSUInteger)indexes withObjects:(id _Nullable)objects; 30 | 31 | /** 32 | 是否隐藏当前显示View 33 | */ 34 | @property (nonatomic, assign) BOOL hiddenView; 35 | 36 | /** 37 | 不选中Segment时文本的颜色 38 | */ 39 | @property (nonatomic, strong) UIColor * _Nullable titleTextColor UI_APPEARANCE_SELECTOR; 40 | 41 | /** 42 | 选中Segment文本的颜色 43 | */ 44 | @property (nonatomic, strong) UIColor * _Nullable selectedTitleTextColor UI_APPEARANCE_SELECTOR; 45 | 46 | /** 47 | Segment需要显示的文本字体 48 | */ 49 | @property (nonatomic, strong) UIFont * _Nullable titleTextFont; 50 | 51 | /** 52 | 未选中Segment后的图标 53 | */ 54 | @property (nonatomic, copy) NSString * _Nullable segmentImage; 55 | 56 | /** 57 | 选中Segment后的图标 58 | */ 59 | @property (nonatomic, copy) NSString * _Nullable selectSegmentImage; 60 | 61 | /** 62 | 线条Segment的颜色 63 | */ 64 | @property (nonatomic, strong) UIColor * _Nullable segmentlineColor; 65 | 66 | /** 67 | 未选中Segment的背景色 68 | */ 69 | @property (nonatomic, strong) UIColor * _Nullable segmentbackColor; 70 | 71 | /** 72 | 选中Segment的背景色 73 | */ 74 | @property (nonatomic, strong) UIColor * _Nullable selectSegmentbackColor; 75 | 76 | /** 77 | 未选中Segment的背景图片 78 | */ 79 | @property (nonatomic, strong) UIImage * _Nullable segmentbackImage; 80 | 81 | /** 82 | 选中Segment的背景图片 83 | */ 84 | @property (nonatomic, strong) UIImage * _Nullable selectSegmentbackImage; 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /CQTopBar/CQTopBar/CQTopBarView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CQTopBarView.m 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/9. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import "CQTopBarView.h" 10 | #import "CQTopBarSegment.h" 11 | #import "CQTopBarFiltrateView.h" 12 | #import "CQTopBarSegmentCell.h" 13 | 14 | 15 | #define IPHONE_X \ 16 | ({BOOL isPhoneX = NO;\ 17 | if (@available(iOS 11.0, *)) {\ 18 | isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\ 19 | }\ 20 | (isPhoneX);})\ 21 | 22 | #define KScreenHeight [[UIScreen mainScreen] bounds].size.height 23 | 24 | @interface CQTopBarView () 25 | @property (nonatomic, strong) CQTopBarSegment *segment; 26 | @property (nonatomic, strong) CQTopBarFiltrateView *barView; 27 | @end 28 | 29 | @implementation CQTopBarView 30 | 31 | - (instancetype _Nonnull)initWithFrame:(CGRect)frame 32 | ContentView:(UIView *)contentView 33 | SectionTitles:(NSArray *_Nonnull)sectionTitles 34 | PageViews:(NSArray *_Nonnull)pageViews{ 35 | CGFloat segmentY = frame.origin.y; 36 | CGFloat segmentH = frame.size.height; 37 | CGFloat barViewH = KScreenHeight - [self currentDeviceTabbarBottomHeight] - segmentY - segmentH; 38 | CGRect topBarFrame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, barViewH); 39 | self = [super initWithFrame:topBarFrame]; 40 | if (self) { 41 | self.backgroundColor = [UIColor whiteColor]; 42 | if (sectionTitles.count == 0 || pageViews.count == 0){ 43 | NSLog(@"数据不能不为空"); 44 | }else if (sectionTitles.count != pageViews.count){ 45 | NSLog(@"两个数组大小必须一致"); 46 | }else{ 47 | [self initUIWithSectionTitles:sectionTitles 48 | pageViews:pageViews 49 | ContentView:contentView 50 | segmentH:segmentH 51 | barViewH:barViewH]; 52 | } 53 | } 54 | return self; 55 | } 56 | 57 | - (void)initUIWithSectionTitles:(NSArray *)sectionTitles 58 | pageViews:(NSArray *)pageViews 59 | ContentView:(UIView *)contentView 60 | segmentH:(CGFloat)segmentH 61 | barViewH:(CGFloat)barViewH{ 62 | CGFloat segmentW = self.frame.size.width; 63 | self.segment = [[CQTopBarSegment alloc] initWithFrame:CGRectMake(0, 0, segmentW, segmentH) sectionTitles:sectionTitles]; 64 | self.segment.delegate = self; 65 | [self addSubview:self.segment]; 66 | 67 | CGFloat barViewX = self.frame.origin.x; 68 | CGFloat barViewY = self.segment.frame.size.height; 69 | CGFloat barViewW = self.frame.size.width; 70 | 71 | if (contentView != nil && [contentView isKindOfClass:[UIView class]]){ 72 | contentView.frame = CGRectMake(barViewX, barViewY, barViewW, barViewH); 73 | [self addSubview:contentView]; 74 | } 75 | 76 | self.barView = [[CQTopBarFiltrateView alloc] initWithFrame:CGRectMake(barViewX, barViewY, barViewW, 0) pageViews:pageViews]; 77 | self.barView.delegate = self; 78 | [self addSubview:self.barView]; 79 | } 80 | 81 | - (void)setTitleTextColor:(UIColor *)titleTextColor{ 82 | _titleTextColor = titleTextColor; 83 | self.segment.titleTextColor = titleTextColor; 84 | } 85 | 86 | - (void)setSelectedTitleTextColor:(UIColor *)selectedTitleTextColor{ 87 | _titleTextColor = selectedTitleTextColor; 88 | self.segment.selectedTitleTextColor = selectedTitleTextColor; 89 | } 90 | 91 | - (void)setTitleTextFont:(UIFont *)titleTextFont{ 92 | _titleTextFont = titleTextFont; 93 | self.segment.titleTextFont = titleTextFont; 94 | } 95 | 96 | - (void)setSegmentImage:(NSString *)segmentImage{ 97 | _segmentImage = segmentImage; 98 | self.segment.segmentImage = segmentImage; 99 | } 100 | 101 | - (void)setSelectSegmentImage:(NSString *)selectSegmentImage{ 102 | _selectSegmentImage = selectSegmentImage; 103 | self.segment.selectSegmentImage = selectSegmentImage; 104 | } 105 | 106 | - (void)setSegmentlineColor:(UIColor *)segmentlineColor{ 107 | _segmentlineColor = segmentlineColor; 108 | self.segment.segmentlineColor = segmentlineColor; 109 | } 110 | 111 | - (void)setSegmentbackColor:(UIColor *)segmentbackColor{ 112 | _segmentbackColor = segmentbackColor; 113 | self.segment.segmentbackColor = segmentbackColor; 114 | } 115 | 116 | - (void)setSelectSegmentbackColor:(UIColor *)selectSegmentbackColor{ 117 | _selectSegmentbackColor = selectSegmentbackColor; 118 | self.segment.selectSegmentbackColor = selectSegmentbackColor; 119 | } 120 | 121 | - (void)setSegmentbackImage:(UIImage *)segmentbackImage{ 122 | _segmentbackImage = segmentbackImage; 123 | self.segment.segmentbackImage = segmentbackImage; 124 | } 125 | 126 | - (void)setSelectSegmentbackImage:(UIImage *)selectSegmentbackImage{ 127 | _selectSegmentbackImage = selectSegmentbackImage; 128 | self.segment.selectSegmentbackImage = selectSegmentbackImage; 129 | } 130 | 131 | - (void)topBarReplaceObjectsAtIndexes:(NSUInteger)indexes withObjects:(id)objects{ 132 | [self.segment topBarReplaceObjectsAtIndexes:indexes withObjects:objects BarView:self.barView]; 133 | } 134 | 135 | - (void)setHiddenView:(BOOL)hiddenView{ 136 | _hiddenView = hiddenView; 137 | if (hiddenView) { 138 | [self setViewAnimaWithHeight:0]; 139 | [self.segment.collectionView reloadData]; 140 | }else{ 141 | [self setViewAnimaWithHeight:self.frame.size.height]; 142 | } 143 | } 144 | 145 | - (void)topBarSegmentWithBlock:(CQTopBarSegment *)segment indexPath:(NSIndexPath *)indexPath{ 146 | [self setViewAnimaWithHeight:self.frame.size.height]; 147 | [self.barView.topBarCollectionView selectItemAtIndexPath:indexPath animated:NO scrollPosition:UICollectionViewScrollPositionLeft]; 148 | } 149 | 150 | - (void)topBarSegmentWithSegmentView:(CQTopBarSegment *)segmentView{ 151 | [self setViewAnimaWithHeight:0]; 152 | } 153 | 154 | - (void)topBarWithBarView:(CQTopBarView *)segment indexPath:(NSIndexPath *)indexPath{ 155 | CQTopBarSegmentCell *cell = (CQTopBarSegmentCell *)[self.segment.collectionView cellForItemAtIndexPath:indexPath]; 156 | cell.segmentBtn.hidden = YES; 157 | [cell.titleImage setTitleColor:self.titleTextColor==nil?[UIColor blackColor]:self.titleTextColor forState:UIControlStateNormal]; 158 | cell.backgroundColor = self.segmentbackColor == nil?[UIColor whiteColor]:self.segmentbackColor; 159 | [cell.titleImage setImage:[UIImage imageNamed:self.segmentImage==nil?@"":self.segmentImage] forState:UIControlStateNormal]; 160 | [self setViewAnimaWithHeight:0]; 161 | } 162 | 163 | - (void)setViewAnimaWithHeight:(CGFloat)height{ 164 | CGRect rect = self.barView.frame; 165 | rect.size.height = height; 166 | self.barView.frame = rect; 167 | } 168 | 169 | - (CGFloat)currentDeviceTabbarBottomHeight{ 170 | if (IPHONE_X){ 171 | return 34; 172 | } 173 | return 0; 174 | } 175 | 176 | @end 177 | -------------------------------------------------------------------------------- /CQTopBar/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 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 | -------------------------------------------------------------------------------- /CQTopBar/Text1.h: -------------------------------------------------------------------------------- 1 | // 2 | // Text1.h 3 | // CQTopBar 4 | // 5 | // Created by yto on 2018/1/22. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Text1 : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /CQTopBar/Text1.m: -------------------------------------------------------------------------------- 1 | // 2 | // Text1.m 3 | // CQTopBar 4 | // 5 | // Created by yto on 2018/1/22. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import "Text1.h" 10 | #define KScreenWidth [[UIScreen mainScreen] bounds].size.width 11 | @interface Text1 () 12 | 13 | @end 14 | 15 | @implementation Text1 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 200)]; 20 | view.backgroundColor = [UIColor yellowColor]; 21 | [self.view addSubview:view]; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /CQTopBar/Text3.h: -------------------------------------------------------------------------------- 1 | // 2 | // Text3.h 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/22. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Text3 : UIViewController 12 | @property (copy, nonatomic) void(^titleLabel)(NSString *str); 13 | @end 14 | -------------------------------------------------------------------------------- /CQTopBar/Text3.m: -------------------------------------------------------------------------------- 1 | // 2 | // Text3.m 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/22. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import "Text3.h" 10 | #define KScreenWidth [[UIScreen mainScreen] bounds].size.width 11 | @interface Text3 () 12 | 13 | @end 14 | 15 | @implementation Text3 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 350)]; 20 | table.delegate = self; 21 | table.dataSource = self; 22 | [self.view addSubview:table]; 23 | } 24 | 25 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 26 | return 15; 27 | } 28 | 29 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 30 | static NSString *ID = @"Text3Cell"; 31 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; 32 | if (cell == nil) { 33 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID]; 34 | } 35 | cell.textLabel.text = [NSString stringWithFormat:@"text%zd",indexPath.row]; 36 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 37 | return cell; 38 | } 39 | 40 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 41 | NSString *str = [NSString stringWithFormat:@"text%zd",indexPath.row]; 42 | if (self.titleLabel) self.titleLabel(str); 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /CQTopBar/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/9. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /CQTopBar/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/9. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "CQTopBarView.h" 11 | #import "testView1.h" 12 | #import "testView2.h" 13 | #import "testView3.h" 14 | 15 | @interface ViewController () 16 | @property (nonatomic, strong) CQTopBarView *topBar; 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | self.view.backgroundColor = [UIColor whiteColor]; 24 | 25 | testView1 *test1 = [[testView1 alloc] init]; 26 | 27 | testView2 *test2 = [[testView2 alloc] init]; 28 | 29 | testView3 *test3 = [[testView3 alloc] init]; 30 | 31 | UITableView *tableView = [[UITableView alloc] init]; 32 | tableView.delegate = self; 33 | tableView.dataSource = self; 34 | 35 | CGRect topBarFrame = CGRectMake(0, 64, [[UIScreen mainScreen] bounds].size.width, 40); 36 | CQTopBarView *topBar = [[CQTopBarView alloc] initWithFrame:topBarFrame 37 | ContentView:tableView 38 | SectionTitles:@[@"test1",@"test2",@"test3"] 39 | PageViews:@[test1,test2,test3]]; 40 | 41 | topBar.segmentbackImage = [UIImage imageNamed:@"userorder_cancelbtn_highlight"]; 42 | topBar.selectSegmentbackImage = [UIImage imageNamed:@"main_searchbutton_normal"]; 43 | topBar.segmentlineColor = [UIColor whiteColor]; 44 | [self.view addSubview:topBar]; 45 | 46 | [test1 setTitleLabel:^(NSString * _Nonnull str) { 47 | NSLog(@"test1=====%@",str); 48 | }]; 49 | 50 | } 51 | 52 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 53 | return 20; 54 | } 55 | 56 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 57 | static NSString *ID = @"TableViewCell"; 58 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; 59 | if (cell == nil) { 60 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID]; 61 | } 62 | cell.textLabel.text = @"TableViewCell"; 63 | return cell; 64 | } 65 | 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /CQTopBar/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2018/1/9. 6 | // Copyright © 2018年 CQ. 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 | -------------------------------------------------------------------------------- /CQTopBar/testView1.h: -------------------------------------------------------------------------------- 1 | // 2 | // testView1.h 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2024/6/7. 6 | // Copyright © 2024 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface testView1 : UIView 14 | @property (copy, nonatomic) void(^titleLabel)(NSString *str); 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /CQTopBar/testView1.m: -------------------------------------------------------------------------------- 1 | // 2 | // testView1.m 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2024/6/7. 6 | // Copyright © 2024 CQ. All rights reserved. 7 | // 8 | 9 | #import "testView1.h" 10 | 11 | #define KScreenWidth [[UIScreen mainScreen] bounds].size.width 12 | @interface testView1 () 13 | 14 | @end 15 | 16 | @implementation testView1 17 | 18 | - (instancetype)init{ 19 | self = [super init]; 20 | if (self) { 21 | UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 300)]; 22 | table.delegate = self; 23 | table.dataSource = self; 24 | [self addSubview:table]; 25 | } 26 | return self; 27 | } 28 | 29 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 30 | return 100; 31 | } 32 | 33 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 34 | static NSString *ID = @"testView1Cell"; 35 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; 36 | if (cell == nil) { 37 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID]; 38 | } 39 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 40 | cell.textLabel.text = [NSString stringWithFormat:@"testView%zd",indexPath.row]; 41 | return cell; 42 | } 43 | 44 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 45 | NSString *str = [NSString stringWithFormat:@"test1View%zd",indexPath.row]; 46 | if (self.titleLabel) self.titleLabel(str); 47 | NSLog(@"testView1 = %@", str); 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /CQTopBar/testView2.h: -------------------------------------------------------------------------------- 1 | // 2 | // testView2.h 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2024/6/7. 6 | // Copyright © 2024 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface testView2 : UIView 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /CQTopBar/testView2.m: -------------------------------------------------------------------------------- 1 | // 2 | // testView2.m 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2024/6/7. 6 | // Copyright © 2024 CQ. All rights reserved. 7 | // 8 | 9 | #import "testView2.h" 10 | 11 | @implementation testView2 12 | 13 | - (instancetype)init 14 | { 15 | self = [super init]; 16 | if (self) { 17 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 200)]; 18 | view.backgroundColor = [UIColor yellowColor]; 19 | [self addSubview:view]; 20 | 21 | UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(50, 100, 100, 100)]; 22 | [button setTitle:@"测试" forState:UIControlStateNormal]; 23 | button.backgroundColor = [UIColor redColor]; 24 | [button addTarget:self action:@selector(select) forControlEvents:UIControlEventTouchUpInside]; 25 | [self addSubview:button]; 26 | } 27 | return self; 28 | } 29 | 30 | - (void)select{ 31 | NSLog(@"测试"); 32 | } 33 | @end 34 | -------------------------------------------------------------------------------- /CQTopBar/testView3.h: -------------------------------------------------------------------------------- 1 | // 2 | // testView3.h 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2024/6/7. 6 | // Copyright © 2024 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface testView3 : UIView 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /CQTopBar/testView3.m: -------------------------------------------------------------------------------- 1 | // 2 | // testView3.m 3 | // CQTopBar 4 | // 5 | // Created by CQ on 2024/6/7. 6 | // Copyright © 2024 CQ. All rights reserved. 7 | // 8 | 9 | #import "testView3.h" 10 | #define KScreenWidth [[UIScreen mainScreen] bounds].size.width 11 | @interface testView3 () 12 | @end 13 | 14 | @implementation testView3 15 | 16 | - (instancetype)init{ 17 | self = [super init]; 18 | if (self) { 19 | UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 300)]; 20 | table.delegate = self; 21 | table.dataSource = self; 22 | [self addSubview:table]; 23 | } 24 | return self; 25 | } 26 | 27 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 28 | return 100; 29 | } 30 | 31 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 32 | static NSString *ID = @"testView1Cell"; 33 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; 34 | if (cell == nil) { 35 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID]; 36 | } 37 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 38 | cell.textLabel.text = [NSString stringWithFormat:@"testView%zd",indexPath.row]; 39 | return cell; 40 | } 41 | 42 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 43 | NSString *str = [NSString stringWithFormat:@"test3View%zd",indexPath.row]; 44 | NSLog(@"testView3 = %@", str); 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /CQTopBarTests/CQTopBarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CQTopBarTests.m 3 | // CQTopBarTests 4 | // 5 | // Created by CQ on 2018/1/9. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CQTopBarTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CQTopBarTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /CQTopBarTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /CQTopBarUITests/CQTopBarUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CQTopBarUITests.m 3 | // CQTopBarUITests 4 | // 5 | // Created by CQ on 2018/1/9. 6 | // Copyright © 2018年 CQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CQTopBarUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CQTopBarUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /CQTopBarUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CQTopBar 2 | ## 控件简介 3 | 快速集成下拉菜单控件,可自定义内容、属性、位置和大小,传入需要显示的标题文字和需要显示的控制器即可,请查看示例程序或者demo。 4 | ### 【注】 5 | - V1.1.5的版本使用是UIView的创建形式,之前使用的是UIViewController的创建形式 6 | - 所传入的标题文字数组和显示的控制器数组个数必须一致。 7 | ### CocoaPods 8 | 9 | 1. Add `pod 'CQTopBar',` to your Podfile. 10 | 11 | 2. Run `pod install` or `pod update`. 12 | 13 | [简书地址](https://www.jianshu.com/p/b8f8f73b0efa) 14 | 15 | ## TopBar(UIViewController的创建形式)【示例】 16 | ```objc 17 | @interface ViewController () 18 | @property (nonatomic, strong) CQTopBarViewController *topBar; 19 | @end 20 | 21 | @implementation ViewController 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | self.view.backgroundColor = [UIColor whiteColor]; 25 | self.topBar = [[CQTopBarViewController alloc] init]; 26 | self.topBar.sectionTitles = @[@"Text1",@"Text2",@"Text3"]; 27 | self.topBar.pageViewClasses = @[[Text1 class],[Text2 class],[Text3 class]]; 28 | [self addChildViewController:self.topBar]; 29 | [self.view addSubview:self.topBar.view]; 30 | 31 | UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.topBar.footerView.bounds.size.height)]; 32 | tableView.delegate = self; 33 | tableView.dataSource = self; 34 | [self.topBar.footerView addSubview:tableView]; 35 | } 36 | ``` 37 | ## TopBar(UIView的创建形式)【示例】 38 | ```objc 39 | testView1 *test1 = [[testView1 alloc] init]; 40 | testView2 *test2 = [[testView2 alloc] init]; 41 | testView3 *test3 = [[testView3 alloc] init]; 42 | UITableView *tableView = [[UITableView alloc] init]; 43 | tableView.delegate = self; 44 | tableView.dataSource = self; 45 | 46 | CGRect topBarFrame = CGRectMake(0, 64, [[UIScreen mainScreen] bounds].size.width, 40); 47 | CQTopBarView *topBar = [[CQTopBarView alloc] initWithFrame:topBarFrame 48 | ContentView:tableView 49 | SectionTitles:@[@"test1",@"test2",@"test3"] 50 | PageViews:@[test1,test2,test3]]; 51 | 52 | topBar.segmentbackImage = [UIImage imageNamed:@"userorder_cancelbtn_highlight"]; 53 | topBar.selectSegmentbackImage = [UIImage imageNamed:@"main_searchbutton_normal"]; 54 | topBar.segmentlineColor = [UIColor whiteColor]; 55 | [self.view addSubview:topBar]; 56 | ``` 57 | 58 | ## 界面显示 59 | 60 | ![image](https://github.com/cq1402272764/CQTopBar/blob/master/Res/TopBar.gif) 61 | -------------------------------------------------------------------------------- /Res/TopBar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cq1402272764/CQTopBar/eb27ed25e0a35f78365c51056b434472a0469d4c/Res/TopBar.gif --------------------------------------------------------------------------------