├── .github └── workflows │ └── objective-c-xcode.yml ├── .gitignore ├── FMTagsView.podspec ├── FMTagsView.xcodeproj └── project.pbxproj ├── FMTagsView ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Controller │ ├── CustomerViewController.h │ ├── CustomerViewController.m │ ├── FMAddTagsController.h │ ├── FMAddTagsController.m │ ├── FMHotSearchController.h │ ├── FMHotSearchController.m │ ├── MultipleSelectTestController.h │ └── MultipleSelectTestController.m ├── Info.plist ├── TagsView │ ├── FMTagsView.h │ └── FMTagsView.m ├── ViewController.h ├── ViewController.m └── main.m ├── FMTagsViewTests ├── FMTagsViewTests.m └── Info.plist ├── FMTagsViewUITests ├── FMTagsViewUITests.m └── Info.plist ├── LICENSE ├── Podfile ├── Podfile.lock ├── README.md └── Screenshots ├── aaaa.gif └── bbb.gif /.github/workflows/objective-c-xcode.yml: -------------------------------------------------------------------------------- 1 | name: Xcode - Build and Analyze 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | jobs: 10 | build: 11 | name: Build and analyse default scheme using xcodebuild command 12 | runs-on: macos-latest 13 | 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v3 17 | - name: Set Default Scheme 18 | run: | 19 | scheme_list=$(xcodebuild -list -json | tr -d "\n") 20 | default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]") 21 | echo $default | cat >default 22 | echo Using default scheme: $default 23 | - name: Build 24 | env: 25 | scheme: ${{ 'default' }} 26 | run: | 27 | if [ $scheme = default ]; then scheme=$(cat default); fi 28 | if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi 29 | file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` 30 | xcodebuild clean build analyze -scheme "$scheme" -"$filetype_parameter" "$file_to_build" | xcpretty && exit ${PIPESTATUS[0]} 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | 19 | ## Other 20 | *.moved-aside 21 | *.xccheckout 22 | *.xcscmblueprint 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | 28 | # CocoaPods 29 | # 30 | # We recommend against adding the Pods directory to your .gitignore. However 31 | # you should judge for yourself, the pros and cons are mentioned at: 32 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 33 | # 34 | # 35 | Pods/ 36 | 37 | # Carthage 38 | # 39 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 40 | # Carthage/Checkouts 41 | 42 | Carthage/Build -------------------------------------------------------------------------------- /FMTagsView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'FMTagsView' 3 | s.summary = '一个基于UICollectionView的标签展示控件 .' 4 | s.version = '0.1.7' 5 | s.license = { :type => 'MIT', :file => 'LICENSE' } 6 | s.authors = { 'Subo' => '455295813@qq.com' } 7 | s.social_media_url = 'https://github.com/lexiaoyao20' 8 | s.homepage = 'https://github.com/lexiaoyao20/FMTagsView' 9 | s.platform = :ios, '7.0' 10 | s.ios.deployment_target = '7.0' 11 | s.source = { :git => 'https://github.com/lexiaoyao20/FMTagsView.git', :tag => s.version.to_s } 12 | 13 | s.requires_arc = true 14 | s.source_files = 'FMTagsView/TagsView/**/*.{h,m}' 15 | s.public_header_files = 'FMTagsView/TagsView/**/*.{h}' 16 | 17 | s.framework = 'UIKit' 18 | 19 | end -------------------------------------------------------------------------------- /FMTagsView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3CF43FBAE41EFEE6E21FEA19 /* libPods-FMTagsView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BD8261601F0E36B06F119D49 /* libPods-FMTagsView.a */; }; 11 | 9310A4241CF54624005DEAB5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9310A4231CF54624005DEAB5 /* main.m */; }; 12 | 9310A4271CF54624005DEAB5 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9310A4261CF54624005DEAB5 /* AppDelegate.m */; }; 13 | 9310A42A1CF54624005DEAB5 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9310A4291CF54624005DEAB5 /* ViewController.m */; }; 14 | 9310A42D1CF54624005DEAB5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9310A42B1CF54624005DEAB5 /* Main.storyboard */; }; 15 | 9310A42F1CF54624005DEAB5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9310A42E1CF54624005DEAB5 /* Assets.xcassets */; }; 16 | 9310A4321CF54624005DEAB5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9310A4301CF54624005DEAB5 /* LaunchScreen.storyboard */; }; 17 | 9310A43D1CF54624005DEAB5 /* FMTagsViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9310A43C1CF54624005DEAB5 /* FMTagsViewTests.m */; }; 18 | 9310A4481CF54624005DEAB5 /* FMTagsViewUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9310A4471CF54624005DEAB5 /* FMTagsViewUITests.m */; }; 19 | 9310A45B1CF54664005DEAB5 /* FMTagsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9310A45A1CF54664005DEAB5 /* FMTagsView.m */; }; 20 | 931D6C8324304F0200518D3D /* MultipleSelectTestController.m in Sources */ = {isa = PBXBuildFile; fileRef = 931D6C8224304F0200518D3D /* MultipleSelectTestController.m */; }; 21 | 934418411F29771E00C99C79 /* CustomerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 934418401F29771E00C99C79 /* CustomerViewController.m */; }; 22 | 93A124791CF82AF4007070E1 /* FMHotSearchController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93A124781CF82AF4007070E1 /* FMHotSearchController.m */; }; 23 | 93A1247C1CF8393D007070E1 /* FMAddTagsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93A1247B1CF8393D007070E1 /* FMAddTagsController.m */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXContainerItemProxy section */ 27 | 9310A4391CF54624005DEAB5 /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = 9310A4171CF54624005DEAB5 /* Project object */; 30 | proxyType = 1; 31 | remoteGlobalIDString = 9310A41E1CF54624005DEAB5; 32 | remoteInfo = FMTagsView; 33 | }; 34 | 9310A4441CF54624005DEAB5 /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = 9310A4171CF54624005DEAB5 /* Project object */; 37 | proxyType = 1; 38 | remoteGlobalIDString = 9310A41E1CF54624005DEAB5; 39 | remoteInfo = FMTagsView; 40 | }; 41 | /* End PBXContainerItemProxy section */ 42 | 43 | /* Begin PBXFileReference section */ 44 | 08EA5CEDB8212B7617735543 /* Pods-FMTagsView.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FMTagsView.debug.xcconfig"; path = "Pods/Target Support Files/Pods-FMTagsView/Pods-FMTagsView.debug.xcconfig"; sourceTree = ""; }; 45 | 9310A41F1CF54624005DEAB5 /* FMTagsView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FMTagsView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | 9310A4231CF54624005DEAB5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 47 | 9310A4251CF54624005DEAB5 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 48 | 9310A4261CF54624005DEAB5 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 49 | 9310A4281CF54624005DEAB5 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 50 | 9310A4291CF54624005DEAB5 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 51 | 9310A42C1CF54624005DEAB5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 52 | 9310A42E1CF54624005DEAB5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 53 | 9310A4311CF54624005DEAB5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 54 | 9310A4331CF54624005DEAB5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 9310A4381CF54624005DEAB5 /* FMTagsViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FMTagsViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | 9310A43C1CF54624005DEAB5 /* FMTagsViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FMTagsViewTests.m; sourceTree = ""; }; 57 | 9310A43E1CF54624005DEAB5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 58 | 9310A4431CF54624005DEAB5 /* FMTagsViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FMTagsViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 59 | 9310A4471CF54624005DEAB5 /* FMTagsViewUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FMTagsViewUITests.m; sourceTree = ""; }; 60 | 9310A4491CF54624005DEAB5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 61 | 9310A4591CF54664005DEAB5 /* FMTagsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMTagsView.h; sourceTree = ""; }; 62 | 9310A45A1CF54664005DEAB5 /* FMTagsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMTagsView.m; sourceTree = ""; }; 63 | 931D6C8124304F0200518D3D /* MultipleSelectTestController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MultipleSelectTestController.h; sourceTree = ""; }; 64 | 931D6C8224304F0200518D3D /* MultipleSelectTestController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MultipleSelectTestController.m; sourceTree = ""; }; 65 | 9344183F1F29771E00C99C79 /* CustomerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomerViewController.h; sourceTree = ""; }; 66 | 934418401F29771E00C99C79 /* CustomerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomerViewController.m; sourceTree = ""; }; 67 | 93A124771CF82AF4007070E1 /* FMHotSearchController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMHotSearchController.h; sourceTree = ""; }; 68 | 93A124781CF82AF4007070E1 /* FMHotSearchController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMHotSearchController.m; sourceTree = ""; }; 69 | 93A1247A1CF8393D007070E1 /* FMAddTagsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMAddTagsController.h; sourceTree = ""; }; 70 | 93A1247B1CF8393D007070E1 /* FMAddTagsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMAddTagsController.m; sourceTree = ""; }; 71 | 9D3D49463777F8439CAED1C7 /* Pods-FMTagsView.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FMTagsView.release.xcconfig"; path = "Pods/Target Support Files/Pods-FMTagsView/Pods-FMTagsView.release.xcconfig"; sourceTree = ""; }; 72 | BD8261601F0E36B06F119D49 /* libPods-FMTagsView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-FMTagsView.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 73 | /* End PBXFileReference section */ 74 | 75 | /* Begin PBXFrameworksBuildPhase section */ 76 | 9310A41C1CF54624005DEAB5 /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | 3CF43FBAE41EFEE6E21FEA19 /* libPods-FMTagsView.a in Frameworks */, 81 | ); 82 | runOnlyForDeploymentPostprocessing = 0; 83 | }; 84 | 9310A4351CF54624005DEAB5 /* Frameworks */ = { 85 | isa = PBXFrameworksBuildPhase; 86 | buildActionMask = 2147483647; 87 | files = ( 88 | ); 89 | runOnlyForDeploymentPostprocessing = 0; 90 | }; 91 | 9310A4401CF54624005DEAB5 /* Frameworks */ = { 92 | isa = PBXFrameworksBuildPhase; 93 | buildActionMask = 2147483647; 94 | files = ( 95 | ); 96 | runOnlyForDeploymentPostprocessing = 0; 97 | }; 98 | /* End PBXFrameworksBuildPhase section */ 99 | 100 | /* Begin PBXGroup section */ 101 | 1B733E01A0C6D6BDAE319453 /* Frameworks */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | BD8261601F0E36B06F119D49 /* libPods-FMTagsView.a */, 105 | ); 106 | name = Frameworks; 107 | sourceTree = ""; 108 | }; 109 | 712FFB7FE72901B38097BA3D /* Pods */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 08EA5CEDB8212B7617735543 /* Pods-FMTagsView.debug.xcconfig */, 113 | 9D3D49463777F8439CAED1C7 /* Pods-FMTagsView.release.xcconfig */, 114 | ); 115 | name = Pods; 116 | sourceTree = ""; 117 | }; 118 | 9310A4161CF54624005DEAB5 = { 119 | isa = PBXGroup; 120 | children = ( 121 | 9310A4211CF54624005DEAB5 /* FMTagsView */, 122 | 9310A43B1CF54624005DEAB5 /* FMTagsViewTests */, 123 | 9310A4461CF54624005DEAB5 /* FMTagsViewUITests */, 124 | 9310A4201CF54624005DEAB5 /* Products */, 125 | 712FFB7FE72901B38097BA3D /* Pods */, 126 | 1B733E01A0C6D6BDAE319453 /* Frameworks */, 127 | ); 128 | sourceTree = ""; 129 | }; 130 | 9310A4201CF54624005DEAB5 /* Products */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | 9310A41F1CF54624005DEAB5 /* FMTagsView.app */, 134 | 9310A4381CF54624005DEAB5 /* FMTagsViewTests.xctest */, 135 | 9310A4431CF54624005DEAB5 /* FMTagsViewUITests.xctest */, 136 | ); 137 | name = Products; 138 | sourceTree = ""; 139 | }; 140 | 9310A4211CF54624005DEAB5 /* FMTagsView */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | 93A124761CF82ADE007070E1 /* Controller */, 144 | 9310A4581CF54664005DEAB5 /* TagsView */, 145 | 9310A4251CF54624005DEAB5 /* AppDelegate.h */, 146 | 9310A4261CF54624005DEAB5 /* AppDelegate.m */, 147 | 9310A4281CF54624005DEAB5 /* ViewController.h */, 148 | 9310A4291CF54624005DEAB5 /* ViewController.m */, 149 | 9310A42B1CF54624005DEAB5 /* Main.storyboard */, 150 | 9310A42E1CF54624005DEAB5 /* Assets.xcassets */, 151 | 9310A4301CF54624005DEAB5 /* LaunchScreen.storyboard */, 152 | 9310A4331CF54624005DEAB5 /* Info.plist */, 153 | 9310A4221CF54624005DEAB5 /* Supporting Files */, 154 | ); 155 | path = FMTagsView; 156 | sourceTree = ""; 157 | }; 158 | 9310A4221CF54624005DEAB5 /* Supporting Files */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | 9310A4231CF54624005DEAB5 /* main.m */, 162 | ); 163 | name = "Supporting Files"; 164 | sourceTree = ""; 165 | }; 166 | 9310A43B1CF54624005DEAB5 /* FMTagsViewTests */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | 9310A43C1CF54624005DEAB5 /* FMTagsViewTests.m */, 170 | 9310A43E1CF54624005DEAB5 /* Info.plist */, 171 | ); 172 | path = FMTagsViewTests; 173 | sourceTree = ""; 174 | }; 175 | 9310A4461CF54624005DEAB5 /* FMTagsViewUITests */ = { 176 | isa = PBXGroup; 177 | children = ( 178 | 9310A4471CF54624005DEAB5 /* FMTagsViewUITests.m */, 179 | 9310A4491CF54624005DEAB5 /* Info.plist */, 180 | ); 181 | path = FMTagsViewUITests; 182 | sourceTree = ""; 183 | }; 184 | 9310A4581CF54664005DEAB5 /* TagsView */ = { 185 | isa = PBXGroup; 186 | children = ( 187 | 9310A4591CF54664005DEAB5 /* FMTagsView.h */, 188 | 9310A45A1CF54664005DEAB5 /* FMTagsView.m */, 189 | ); 190 | path = TagsView; 191 | sourceTree = ""; 192 | }; 193 | 93A124761CF82ADE007070E1 /* Controller */ = { 194 | isa = PBXGroup; 195 | children = ( 196 | 93A124771CF82AF4007070E1 /* FMHotSearchController.h */, 197 | 93A124781CF82AF4007070E1 /* FMHotSearchController.m */, 198 | 93A1247A1CF8393D007070E1 /* FMAddTagsController.h */, 199 | 93A1247B1CF8393D007070E1 /* FMAddTagsController.m */, 200 | 9344183F1F29771E00C99C79 /* CustomerViewController.h */, 201 | 934418401F29771E00C99C79 /* CustomerViewController.m */, 202 | 931D6C8124304F0200518D3D /* MultipleSelectTestController.h */, 203 | 931D6C8224304F0200518D3D /* MultipleSelectTestController.m */, 204 | ); 205 | path = Controller; 206 | sourceTree = ""; 207 | }; 208 | /* End PBXGroup section */ 209 | 210 | /* Begin PBXNativeTarget section */ 211 | 9310A41E1CF54624005DEAB5 /* FMTagsView */ = { 212 | isa = PBXNativeTarget; 213 | buildConfigurationList = 9310A44C1CF54624005DEAB5 /* Build configuration list for PBXNativeTarget "FMTagsView" */; 214 | buildPhases = ( 215 | 12F34B32172934F90F9306D3 /* [CP] Check Pods Manifest.lock */, 216 | 9310A41B1CF54624005DEAB5 /* Sources */, 217 | 9310A41C1CF54624005DEAB5 /* Frameworks */, 218 | 9310A41D1CF54624005DEAB5 /* Resources */, 219 | ); 220 | buildRules = ( 221 | ); 222 | dependencies = ( 223 | ); 224 | name = FMTagsView; 225 | productName = FMTagsView; 226 | productReference = 9310A41F1CF54624005DEAB5 /* FMTagsView.app */; 227 | productType = "com.apple.product-type.application"; 228 | }; 229 | 9310A4371CF54624005DEAB5 /* FMTagsViewTests */ = { 230 | isa = PBXNativeTarget; 231 | buildConfigurationList = 9310A44F1CF54624005DEAB5 /* Build configuration list for PBXNativeTarget "FMTagsViewTests" */; 232 | buildPhases = ( 233 | 9310A4341CF54624005DEAB5 /* Sources */, 234 | 9310A4351CF54624005DEAB5 /* Frameworks */, 235 | 9310A4361CF54624005DEAB5 /* Resources */, 236 | ); 237 | buildRules = ( 238 | ); 239 | dependencies = ( 240 | 9310A43A1CF54624005DEAB5 /* PBXTargetDependency */, 241 | ); 242 | name = FMTagsViewTests; 243 | productName = FMTagsViewTests; 244 | productReference = 9310A4381CF54624005DEAB5 /* FMTagsViewTests.xctest */; 245 | productType = "com.apple.product-type.bundle.unit-test"; 246 | }; 247 | 9310A4421CF54624005DEAB5 /* FMTagsViewUITests */ = { 248 | isa = PBXNativeTarget; 249 | buildConfigurationList = 9310A4521CF54624005DEAB5 /* Build configuration list for PBXNativeTarget "FMTagsViewUITests" */; 250 | buildPhases = ( 251 | 9310A43F1CF54624005DEAB5 /* Sources */, 252 | 9310A4401CF54624005DEAB5 /* Frameworks */, 253 | 9310A4411CF54624005DEAB5 /* Resources */, 254 | ); 255 | buildRules = ( 256 | ); 257 | dependencies = ( 258 | 9310A4451CF54624005DEAB5 /* PBXTargetDependency */, 259 | ); 260 | name = FMTagsViewUITests; 261 | productName = FMTagsViewUITests; 262 | productReference = 9310A4431CF54624005DEAB5 /* FMTagsViewUITests.xctest */; 263 | productType = "com.apple.product-type.bundle.ui-testing"; 264 | }; 265 | /* End PBXNativeTarget section */ 266 | 267 | /* Begin PBXProject section */ 268 | 9310A4171CF54624005DEAB5 /* Project object */ = { 269 | isa = PBXProject; 270 | attributes = { 271 | LastUpgradeCheck = 0730; 272 | ORGANIZATIONNAME = Followme; 273 | TargetAttributes = { 274 | 9310A41E1CF54624005DEAB5 = { 275 | CreatedOnToolsVersion = 7.3.1; 276 | ProvisioningStyle = Manual; 277 | }; 278 | 9310A4371CF54624005DEAB5 = { 279 | CreatedOnToolsVersion = 7.3.1; 280 | TestTargetID = 9310A41E1CF54624005DEAB5; 281 | }; 282 | 9310A4421CF54624005DEAB5 = { 283 | CreatedOnToolsVersion = 7.3.1; 284 | TestTargetID = 9310A41E1CF54624005DEAB5; 285 | }; 286 | }; 287 | }; 288 | buildConfigurationList = 9310A41A1CF54624005DEAB5 /* Build configuration list for PBXProject "FMTagsView" */; 289 | compatibilityVersion = "Xcode 3.2"; 290 | developmentRegion = English; 291 | hasScannedForEncodings = 0; 292 | knownRegions = ( 293 | English, 294 | en, 295 | Base, 296 | ); 297 | mainGroup = 9310A4161CF54624005DEAB5; 298 | productRefGroup = 9310A4201CF54624005DEAB5 /* Products */; 299 | projectDirPath = ""; 300 | projectRoot = ""; 301 | targets = ( 302 | 9310A41E1CF54624005DEAB5 /* FMTagsView */, 303 | 9310A4371CF54624005DEAB5 /* FMTagsViewTests */, 304 | 9310A4421CF54624005DEAB5 /* FMTagsViewUITests */, 305 | ); 306 | }; 307 | /* End PBXProject section */ 308 | 309 | /* Begin PBXResourcesBuildPhase section */ 310 | 9310A41D1CF54624005DEAB5 /* Resources */ = { 311 | isa = PBXResourcesBuildPhase; 312 | buildActionMask = 2147483647; 313 | files = ( 314 | 9310A4321CF54624005DEAB5 /* LaunchScreen.storyboard in Resources */, 315 | 9310A42F1CF54624005DEAB5 /* Assets.xcassets in Resources */, 316 | 9310A42D1CF54624005DEAB5 /* Main.storyboard in Resources */, 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | 9310A4361CF54624005DEAB5 /* Resources */ = { 321 | isa = PBXResourcesBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | ); 325 | runOnlyForDeploymentPostprocessing = 0; 326 | }; 327 | 9310A4411CF54624005DEAB5 /* Resources */ = { 328 | isa = PBXResourcesBuildPhase; 329 | buildActionMask = 2147483647; 330 | files = ( 331 | ); 332 | runOnlyForDeploymentPostprocessing = 0; 333 | }; 334 | /* End PBXResourcesBuildPhase section */ 335 | 336 | /* Begin PBXShellScriptBuildPhase section */ 337 | 12F34B32172934F90F9306D3 /* [CP] Check Pods Manifest.lock */ = { 338 | isa = PBXShellScriptBuildPhase; 339 | buildActionMask = 2147483647; 340 | files = ( 341 | ); 342 | inputPaths = ( 343 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 344 | "${PODS_ROOT}/Manifest.lock", 345 | ); 346 | name = "[CP] Check Pods Manifest.lock"; 347 | outputPaths = ( 348 | "$(DERIVED_FILE_DIR)/Pods-FMTagsView-checkManifestLockResult.txt", 349 | ); 350 | runOnlyForDeploymentPostprocessing = 0; 351 | shellPath = /bin/sh; 352 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 353 | showEnvVarsInLog = 0; 354 | }; 355 | /* End PBXShellScriptBuildPhase section */ 356 | 357 | /* Begin PBXSourcesBuildPhase section */ 358 | 9310A41B1CF54624005DEAB5 /* Sources */ = { 359 | isa = PBXSourcesBuildPhase; 360 | buildActionMask = 2147483647; 361 | files = ( 362 | 934418411F29771E00C99C79 /* CustomerViewController.m in Sources */, 363 | 931D6C8324304F0200518D3D /* MultipleSelectTestController.m in Sources */, 364 | 9310A45B1CF54664005DEAB5 /* FMTagsView.m in Sources */, 365 | 93A1247C1CF8393D007070E1 /* FMAddTagsController.m in Sources */, 366 | 9310A42A1CF54624005DEAB5 /* ViewController.m in Sources */, 367 | 9310A4271CF54624005DEAB5 /* AppDelegate.m in Sources */, 368 | 9310A4241CF54624005DEAB5 /* main.m in Sources */, 369 | 93A124791CF82AF4007070E1 /* FMHotSearchController.m in Sources */, 370 | ); 371 | runOnlyForDeploymentPostprocessing = 0; 372 | }; 373 | 9310A4341CF54624005DEAB5 /* Sources */ = { 374 | isa = PBXSourcesBuildPhase; 375 | buildActionMask = 2147483647; 376 | files = ( 377 | 9310A43D1CF54624005DEAB5 /* FMTagsViewTests.m in Sources */, 378 | ); 379 | runOnlyForDeploymentPostprocessing = 0; 380 | }; 381 | 9310A43F1CF54624005DEAB5 /* Sources */ = { 382 | isa = PBXSourcesBuildPhase; 383 | buildActionMask = 2147483647; 384 | files = ( 385 | 9310A4481CF54624005DEAB5 /* FMTagsViewUITests.m in Sources */, 386 | ); 387 | runOnlyForDeploymentPostprocessing = 0; 388 | }; 389 | /* End PBXSourcesBuildPhase section */ 390 | 391 | /* Begin PBXTargetDependency section */ 392 | 9310A43A1CF54624005DEAB5 /* PBXTargetDependency */ = { 393 | isa = PBXTargetDependency; 394 | target = 9310A41E1CF54624005DEAB5 /* FMTagsView */; 395 | targetProxy = 9310A4391CF54624005DEAB5 /* PBXContainerItemProxy */; 396 | }; 397 | 9310A4451CF54624005DEAB5 /* PBXTargetDependency */ = { 398 | isa = PBXTargetDependency; 399 | target = 9310A41E1CF54624005DEAB5 /* FMTagsView */; 400 | targetProxy = 9310A4441CF54624005DEAB5 /* PBXContainerItemProxy */; 401 | }; 402 | /* End PBXTargetDependency section */ 403 | 404 | /* Begin PBXVariantGroup section */ 405 | 9310A42B1CF54624005DEAB5 /* Main.storyboard */ = { 406 | isa = PBXVariantGroup; 407 | children = ( 408 | 9310A42C1CF54624005DEAB5 /* Base */, 409 | ); 410 | name = Main.storyboard; 411 | sourceTree = ""; 412 | }; 413 | 9310A4301CF54624005DEAB5 /* LaunchScreen.storyboard */ = { 414 | isa = PBXVariantGroup; 415 | children = ( 416 | 9310A4311CF54624005DEAB5 /* Base */, 417 | ); 418 | name = LaunchScreen.storyboard; 419 | sourceTree = ""; 420 | }; 421 | /* End PBXVariantGroup section */ 422 | 423 | /* Begin XCBuildConfiguration section */ 424 | 9310A44A1CF54624005DEAB5 /* Debug */ = { 425 | isa = XCBuildConfiguration; 426 | buildSettings = { 427 | ALWAYS_SEARCH_USER_PATHS = NO; 428 | CLANG_ANALYZER_NONNULL = YES; 429 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 430 | CLANG_CXX_LIBRARY = "libc++"; 431 | CLANG_ENABLE_MODULES = YES; 432 | CLANG_ENABLE_OBJC_ARC = YES; 433 | CLANG_WARN_BOOL_CONVERSION = YES; 434 | CLANG_WARN_CONSTANT_CONVERSION = YES; 435 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 436 | CLANG_WARN_EMPTY_BODY = YES; 437 | CLANG_WARN_ENUM_CONVERSION = YES; 438 | CLANG_WARN_INT_CONVERSION = YES; 439 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 440 | CLANG_WARN_UNREACHABLE_CODE = YES; 441 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 442 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 443 | COPY_PHASE_STRIP = NO; 444 | DEBUG_INFORMATION_FORMAT = dwarf; 445 | ENABLE_STRICT_OBJC_MSGSEND = YES; 446 | ENABLE_TESTABILITY = YES; 447 | GCC_C_LANGUAGE_STANDARD = gnu99; 448 | GCC_DYNAMIC_NO_PIC = NO; 449 | GCC_NO_COMMON_BLOCKS = YES; 450 | GCC_OPTIMIZATION_LEVEL = 0; 451 | GCC_PREPROCESSOR_DEFINITIONS = ( 452 | "DEBUG=1", 453 | "$(inherited)", 454 | ); 455 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 456 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 457 | GCC_WARN_UNDECLARED_SELECTOR = YES; 458 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 459 | GCC_WARN_UNUSED_FUNCTION = YES; 460 | GCC_WARN_UNUSED_VARIABLE = YES; 461 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 462 | MTL_ENABLE_DEBUG_INFO = YES; 463 | ONLY_ACTIVE_ARCH = YES; 464 | SDKROOT = iphoneos; 465 | }; 466 | name = Debug; 467 | }; 468 | 9310A44B1CF54624005DEAB5 /* Release */ = { 469 | isa = XCBuildConfiguration; 470 | buildSettings = { 471 | ALWAYS_SEARCH_USER_PATHS = NO; 472 | CLANG_ANALYZER_NONNULL = YES; 473 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 474 | CLANG_CXX_LIBRARY = "libc++"; 475 | CLANG_ENABLE_MODULES = YES; 476 | CLANG_ENABLE_OBJC_ARC = YES; 477 | CLANG_WARN_BOOL_CONVERSION = YES; 478 | CLANG_WARN_CONSTANT_CONVERSION = YES; 479 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 480 | CLANG_WARN_EMPTY_BODY = YES; 481 | CLANG_WARN_ENUM_CONVERSION = YES; 482 | CLANG_WARN_INT_CONVERSION = YES; 483 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 484 | CLANG_WARN_UNREACHABLE_CODE = YES; 485 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 486 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 487 | COPY_PHASE_STRIP = NO; 488 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 489 | ENABLE_NS_ASSERTIONS = NO; 490 | ENABLE_STRICT_OBJC_MSGSEND = YES; 491 | GCC_C_LANGUAGE_STANDARD = gnu99; 492 | GCC_NO_COMMON_BLOCKS = YES; 493 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 494 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 495 | GCC_WARN_UNDECLARED_SELECTOR = YES; 496 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 497 | GCC_WARN_UNUSED_FUNCTION = YES; 498 | GCC_WARN_UNUSED_VARIABLE = YES; 499 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 500 | MTL_ENABLE_DEBUG_INFO = NO; 501 | SDKROOT = iphoneos; 502 | VALIDATE_PRODUCT = YES; 503 | }; 504 | name = Release; 505 | }; 506 | 9310A44D1CF54624005DEAB5 /* Debug */ = { 507 | isa = XCBuildConfiguration; 508 | baseConfigurationReference = 08EA5CEDB8212B7617735543 /* Pods-FMTagsView.debug.xcconfig */; 509 | buildSettings = { 510 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 511 | CODE_SIGN_IDENTITY = "iPhone Developer"; 512 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 513 | CODE_SIGN_STYLE = Manual; 514 | DEVELOPMENT_TEAM = ""; 515 | INFOPLIST_FILE = FMTagsView/Info.plist; 516 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 517 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 518 | MARKETING_VERSION = 0.1.6; 519 | PRODUCT_BUNDLE_IDENTIFIER = com.Followme.FMTagsView; 520 | PRODUCT_NAME = "$(TARGET_NAME)"; 521 | PROVISIONING_PROFILE = ""; 522 | PROVISIONING_PROFILE_SPECIFIER = ""; 523 | }; 524 | name = Debug; 525 | }; 526 | 9310A44E1CF54624005DEAB5 /* Release */ = { 527 | isa = XCBuildConfiguration; 528 | baseConfigurationReference = 9D3D49463777F8439CAED1C7 /* Pods-FMTagsView.release.xcconfig */; 529 | buildSettings = { 530 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 531 | CODE_SIGN_IDENTITY = "iPhone Developer"; 532 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 533 | CODE_SIGN_STYLE = Manual; 534 | DEVELOPMENT_TEAM = ""; 535 | INFOPLIST_FILE = FMTagsView/Info.plist; 536 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 537 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 538 | MARKETING_VERSION = 0.1.6; 539 | PRODUCT_BUNDLE_IDENTIFIER = com.Followme.FMTagsView; 540 | PRODUCT_NAME = "$(TARGET_NAME)"; 541 | PROVISIONING_PROFILE = ""; 542 | PROVISIONING_PROFILE_SPECIFIER = ""; 543 | }; 544 | name = Release; 545 | }; 546 | 9310A4501CF54624005DEAB5 /* Debug */ = { 547 | isa = XCBuildConfiguration; 548 | buildSettings = { 549 | BUNDLE_LOADER = "$(TEST_HOST)"; 550 | INFOPLIST_FILE = FMTagsViewTests/Info.plist; 551 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 552 | PRODUCT_BUNDLE_IDENTIFIER = com.Followme.FMTagsViewTests; 553 | PRODUCT_NAME = "$(TARGET_NAME)"; 554 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FMTagsView.app/FMTagsView"; 555 | }; 556 | name = Debug; 557 | }; 558 | 9310A4511CF54624005DEAB5 /* Release */ = { 559 | isa = XCBuildConfiguration; 560 | buildSettings = { 561 | BUNDLE_LOADER = "$(TEST_HOST)"; 562 | INFOPLIST_FILE = FMTagsViewTests/Info.plist; 563 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 564 | PRODUCT_BUNDLE_IDENTIFIER = com.Followme.FMTagsViewTests; 565 | PRODUCT_NAME = "$(TARGET_NAME)"; 566 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FMTagsView.app/FMTagsView"; 567 | }; 568 | name = Release; 569 | }; 570 | 9310A4531CF54624005DEAB5 /* Debug */ = { 571 | isa = XCBuildConfiguration; 572 | buildSettings = { 573 | INFOPLIST_FILE = FMTagsViewUITests/Info.plist; 574 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 575 | PRODUCT_BUNDLE_IDENTIFIER = com.Followme.FMTagsViewUITests; 576 | PRODUCT_NAME = "$(TARGET_NAME)"; 577 | TEST_TARGET_NAME = FMTagsView; 578 | }; 579 | name = Debug; 580 | }; 581 | 9310A4541CF54624005DEAB5 /* Release */ = { 582 | isa = XCBuildConfiguration; 583 | buildSettings = { 584 | INFOPLIST_FILE = FMTagsViewUITests/Info.plist; 585 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 586 | PRODUCT_BUNDLE_IDENTIFIER = com.Followme.FMTagsViewUITests; 587 | PRODUCT_NAME = "$(TARGET_NAME)"; 588 | TEST_TARGET_NAME = FMTagsView; 589 | }; 590 | name = Release; 591 | }; 592 | /* End XCBuildConfiguration section */ 593 | 594 | /* Begin XCConfigurationList section */ 595 | 9310A41A1CF54624005DEAB5 /* Build configuration list for PBXProject "FMTagsView" */ = { 596 | isa = XCConfigurationList; 597 | buildConfigurations = ( 598 | 9310A44A1CF54624005DEAB5 /* Debug */, 599 | 9310A44B1CF54624005DEAB5 /* Release */, 600 | ); 601 | defaultConfigurationIsVisible = 0; 602 | defaultConfigurationName = Release; 603 | }; 604 | 9310A44C1CF54624005DEAB5 /* Build configuration list for PBXNativeTarget "FMTagsView" */ = { 605 | isa = XCConfigurationList; 606 | buildConfigurations = ( 607 | 9310A44D1CF54624005DEAB5 /* Debug */, 608 | 9310A44E1CF54624005DEAB5 /* Release */, 609 | ); 610 | defaultConfigurationIsVisible = 0; 611 | defaultConfigurationName = Release; 612 | }; 613 | 9310A44F1CF54624005DEAB5 /* Build configuration list for PBXNativeTarget "FMTagsViewTests" */ = { 614 | isa = XCConfigurationList; 615 | buildConfigurations = ( 616 | 9310A4501CF54624005DEAB5 /* Debug */, 617 | 9310A4511CF54624005DEAB5 /* Release */, 618 | ); 619 | defaultConfigurationIsVisible = 0; 620 | defaultConfigurationName = Release; 621 | }; 622 | 9310A4521CF54624005DEAB5 /* Build configuration list for PBXNativeTarget "FMTagsViewUITests" */ = { 623 | isa = XCConfigurationList; 624 | buildConfigurations = ( 625 | 9310A4531CF54624005DEAB5 /* Debug */, 626 | 9310A4541CF54624005DEAB5 /* Release */, 627 | ); 628 | defaultConfigurationIsVisible = 0; 629 | defaultConfigurationName = Release; 630 | }; 631 | /* End XCConfigurationList section */ 632 | }; 633 | rootObject = 9310A4171CF54624005DEAB5 /* Project object */; 634 | } 635 | -------------------------------------------------------------------------------- /FMTagsView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // FMTagsView 4 | // 5 | // Created by Subo on 16/5/25. 6 | // Copyright © 2016年 Followme. 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 | -------------------------------------------------------------------------------- /FMTagsView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // FMTagsView 4 | // 5 | // Created by Subo on 16/5/25. 6 | // Copyright © 2016年 Followme. 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 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /FMTagsView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /FMTagsView/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 | -------------------------------------------------------------------------------- /FMTagsView/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 | 32 | 42 | 53 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 228 | 234 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | -------------------------------------------------------------------------------- /FMTagsView/Controller/CustomerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CustomerViewController.h 3 | // FMTagsView 4 | // 5 | // Created by Subo on 2017/7/27. 6 | // Copyright © 2017年 Followme. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CustomerViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /FMTagsView/Controller/CustomerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomerViewController.m 3 | // FMTagsView 4 | // 5 | // Created by Subo on 2017/7/27. 6 | // Copyright © 2017年 Followme. All rights reserved. 7 | // 8 | 9 | #import "CustomerViewController.h" 10 | #import 11 | #import "FMTagsView.h" 12 | 13 | @interface CustomerViewController () 14 | 15 | @property (nonatomic, weak) UIScrollView *scrollView; 16 | @property (nonatomic, weak) UIView *scrollContentView; 17 | 18 | @property (nonatomic, weak) FMTagsView *tagsView; 19 | @property (strong, nonatomic) NSArray *dataArray; 20 | 21 | @property (nonatomic, weak) UILabel *label1; 22 | @property (nonatomic, weak) FMTagsView *tagsView1; 23 | @property (nonatomic, weak) UILabel *label2; 24 | @property (nonatomic, weak) FMTagsView *tagsView2; 25 | @property (nonatomic, weak) UILabel *label3; 26 | @property (nonatomic, weak) FMTagsView *tagsView3; 27 | 28 | @end 29 | 30 | @implementation CustomerViewController 31 | 32 | - (void)viewDidLoad { 33 | [super viewDidLoad]; 34 | 35 | self.automaticallyAdjustsScrollViewInsets = NO; 36 | [self prepareUI]; 37 | [self setConstraints]; 38 | [self setNavigationBar]; 39 | } 40 | 41 | - (void)didReceiveMemoryWarning { 42 | [super didReceiveMemoryWarning]; 43 | // Dispose of any resources that can be recreated. 44 | } 45 | 46 | - (void)setNavigationBar { 47 | UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"Change Data" 48 | style:UIBarButtonItemStylePlain 49 | target:self 50 | action:@selector(changeDataSource)]; 51 | self.navigationItem.rightBarButtonItem = rightItem; 52 | } 53 | 54 | - (void)changeDataSource { 55 | NSArray *dataArray = @[@"Alta Baronia", @"Alto Tirso", @"Limbara", @"Tirso", @"Gerrei", 56 | @"Capoterra", @"Gutturu Mannu", @"Gennargentu", @"Ogliastra"]; 57 | 58 | NSInteger randomCount = (NSInteger)arc4random_uniform((u_int32_t)dataArray.count); 59 | NSMutableArray *dataArray1 = [NSMutableArray new]; 60 | for(int i = 0; i <= randomCount; i++) { 61 | [dataArray1 addObject:dataArray[i]]; 62 | } 63 | self.tagsView1.tagsArray = dataArray1; 64 | 65 | randomCount = (NSInteger)arc4random_uniform((u_int32_t)dataArray.count); 66 | NSMutableArray *dataArray2 = [NSMutableArray new]; 67 | for(int i = 0; i <= randomCount; i++) { 68 | [dataArray2 addObject:dataArray[i]]; 69 | } 70 | self.tagsView2.tagsArray = dataArray2; 71 | 72 | randomCount = (NSInteger)arc4random_uniform((u_int32_t)dataArray.count); 73 | NSMutableArray *dataArray3 = [NSMutableArray new]; 74 | for(int i = 0; i <= randomCount; i++) { 75 | [dataArray3 addObject:dataArray[i]]; 76 | } 77 | self.tagsView3.tagsArray = dataArray3; 78 | 79 | //update constraints 80 | [UIView animateWithDuration:0.25 animations:^{ 81 | [self.view layoutIfNeeded]; 82 | }]; 83 | } 84 | 85 | - (FMTagsView *)createTagsViewWithDataSrouse:(NSArray *)dataSource borderColor:(UIColor *)borderColor { 86 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width; 87 | CGFloat padding = 15; 88 | //must set the correct width 89 | FMTagsView *tagsView = [[FMTagsView alloc] initWithFrame:CGRectMake(0, 0, screenWidth - padding * 2, 180)]; 90 | tagsView.backgroundColor = [UIColor whiteColor]; 91 | tagsView.delegate = self; 92 | tagsView.contentInsets = UIEdgeInsetsMake(10, 10, 10, 10); 93 | tagsView.tagcornerRadius = 0; 94 | tagsView.layer.borderColor = borderColor.CGColor; 95 | tagsView.layer.borderWidth = 1; 96 | tagsView.tagsArray = dataSource; 97 | 98 | return tagsView; 99 | } 100 | 101 | - (UILabel *)createLabelWithText:(NSString *)text textColor:(UIColor *)textColor { 102 | UILabel *label = [UILabel new]; 103 | label.textColor = textColor; 104 | label.text = text; 105 | label.font = [UIFont boldSystemFontOfSize:17]; 106 | 107 | return label; 108 | } 109 | 110 | - (void)prepareUI { 111 | self.view.backgroundColor = [UIColor whiteColor]; 112 | UIScrollView *scrollView = [UIScrollView new]; 113 | [self.view addSubview:scrollView]; 114 | self.scrollView = scrollView; 115 | 116 | UIView *scrollContentView = [UIView new]; 117 | [self.scrollView addSubview:scrollContentView]; 118 | self.scrollContentView = scrollContentView; 119 | 120 | UILabel *label1 = [self createLabelWithText:@"TagsView1" textColor:[UIColor greenColor]]; 121 | [self.scrollContentView addSubview:label1]; 122 | self.label1 = label1; 123 | 124 | NSArray *dataArray1 = @[@"Alta Baronia", @"Alto Tirso", @"Limbara", @"Tirso", @"Gerrei", 125 | @"Capoterra", @"Gutturu Mannu", @"Gennargentu", @"Ogliastra"]; 126 | FMTagsView *tagsView1 = [self createTagsViewWithDataSrouse:dataArray1 borderColor:[UIColor greenColor]]; 127 | [self.scrollContentView addSubview:tagsView1]; 128 | self.tagsView1 = tagsView1; 129 | 130 | UILabel *label2 = [self createLabelWithText:@"TagsView2" textColor:[UIColor redColor]]; 131 | [self.scrollContentView addSubview:label2]; 132 | self.label2 = label2; 133 | 134 | NSArray *dataArray2 = @[@"Monte Acuto-Meilogu", @"Gallura"]; 135 | FMTagsView *tagsView2 = [self createTagsViewWithDataSrouse:dataArray2 borderColor:[UIColor redColor]]; 136 | [self.scrollContentView addSubview:tagsView2]; 137 | self.tagsView2 = tagsView2; 138 | 139 | UIColor *color3 = [UIColor colorWithRed:0.96 green:0.89 blue:0.2 alpha:1.0]; 140 | UILabel *label3 = [self createLabelWithText:@"TagsView3" textColor:color3]; 141 | [self.scrollContentView addSubview:label3]; 142 | self.label3 = label3; 143 | 144 | NSArray *dataArray3 = @[@"Monte Acuto-Meilogu", @"Gallura"]; 145 | FMTagsView *tagsView3 = [self createTagsViewWithDataSrouse:dataArray3 borderColor:color3]; 146 | [self.scrollContentView addSubview:tagsView3]; 147 | self.tagsView3 = tagsView3; 148 | } 149 | 150 | - (void)setConstraints { 151 | [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make){ 152 | make.top.equalTo(self.mas_topLayoutGuideBottom); 153 | make.left.bottom.right.equalTo(self.view); 154 | }]; 155 | 156 | [self.scrollContentView mas_makeConstraints:^(MASConstraintMaker *make){ 157 | make.edges.equalTo(self.scrollView); 158 | make.width.equalTo(self.scrollView); 159 | }]; 160 | 161 | [self.label1 mas_makeConstraints:^(MASConstraintMaker *make){ 162 | make.top.left.equalTo(self.scrollView).offset(15); 163 | }]; 164 | 165 | [self.tagsView1 mas_makeConstraints:^(MASConstraintMaker *make){ 166 | make.top.equalTo(self.label1.mas_bottom).offset(5); 167 | make.left.equalTo(self.label1); 168 | make.right.equalTo(self.scrollContentView).offset(-15); 169 | }]; 170 | 171 | [self.label2 mas_makeConstraints:^(MASConstraintMaker *make){ 172 | make.top.equalTo(self.tagsView1.mas_bottom).offset(15); 173 | make.left.equalTo(self.label1); 174 | }]; 175 | 176 | [self.tagsView2 mas_makeConstraints:^(MASConstraintMaker *make){ 177 | make.top.equalTo(self.label2.mas_bottom).offset(5); 178 | make.left.equalTo(self.label1); 179 | make.right.equalTo(self.scrollContentView).offset(-15); 180 | }]; 181 | 182 | [self.label3 mas_makeConstraints:^(MASConstraintMaker *make){ 183 | make.top.equalTo(self.tagsView2.mas_bottom).offset(15); 184 | make.left.equalTo(self.label1); 185 | }]; 186 | 187 | [self.tagsView3 mas_makeConstraints:^(MASConstraintMaker *make){ 188 | make.top.equalTo(self.label3.mas_bottom).offset(5); 189 | make.left.equalTo(self.label1); 190 | make.right.equalTo(self.scrollContentView).offset(-15); 191 | }]; 192 | 193 | [self.scrollContentView mas_makeConstraints:^(MASConstraintMaker *make){ 194 | make.bottom.equalTo(self.tagsView3.mas_bottom).offset(10); 195 | }]; 196 | 197 | } 198 | 199 | #pragma mark - ......::::::: FMTagsViewDelegate :::::::...... 200 | 201 | - (void)changeTagCell:(FMTagCell *)tagCell atIndex:(NSUInteger)index { 202 | /* 203 | you can also use a color Array,like so. 204 | NSArray *colorArray .... 205 | UIColor *currentColor = colorArray[index]; 206 | tagCell.backgroundColor = currentColor; 207 | */ 208 | 209 | if (index % 2 == 0) { 210 | tagCell.backgroundColor = [UIColor orangeColor]; 211 | }else { 212 | tagCell.backgroundColor = [UIColor blueColor]; 213 | } 214 | } 215 | 216 | - (void)tagsView:(FMTagsView *)tagsView willDispayCell:(FMTagCell *)tagCell atIndex:(NSUInteger)index { 217 | [self changeTagCell:tagCell atIndex:index]; 218 | } 219 | 220 | - (void)tagsView:(FMTagsView *)tagsView didSelectTagAtIndex:(NSUInteger)index { 221 | //customer apperance while selected tag 222 | } 223 | 224 | - (void)tagsView:(FMTagsView *)tagsView didDeSelectTagAtIndex:(NSUInteger)index { 225 | //customer apperance while unselect tag 226 | FMTagCell *cell = [tagsView cellForItemAtIndex:index]; 227 | if (cell) { 228 | [self changeTagCell:cell atIndex:index]; 229 | } 230 | } 231 | 232 | @end 233 | -------------------------------------------------------------------------------- /FMTagsView/Controller/FMAddTagsController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FMAddTagsController.h 3 | // FMTagsView 4 | // 5 | // Created by Subo on 16/5/27. 6 | // Copyright © 2016年 Followme. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //动态添加标签 12 | @interface FMAddTagsController : UIViewController 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /FMTagsView/Controller/FMAddTagsController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FMAddTagsController.m 3 | // FMTagsView 4 | // 5 | // Created by Subo on 16/5/27. 6 | // Copyright © 2016年 Followme. All rights reserved. 7 | // 8 | 9 | #import "FMAddTagsController.h" 10 | #import "FMTagsView.h" 11 | 12 | @interface FMAddTagsController () 13 | 14 | @property (weak, nonatomic) IBOutlet FMTagsView *tagsView; 15 | @property (weak, nonatomic) IBOutlet UITextField *tagNameTextField; 16 | @property (weak, nonatomic) IBOutlet UITextField *indexTextField; 17 | 18 | @property (strong, nonatomic) NSArray *dataArray; 19 | 20 | @end 21 | 22 | @implementation FMAddTagsController 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | 27 | self.dataArray = @[@"麻棉连衣裙", @"面条", @"亲子装", 28 | @"卫生巾", @"米", @"眉笔", @"蛋糕", 29 | @"面包", @"洗洁精", @"咖啡速溶", 30 | @"云南白药牙膏", @"方便面", @"空调", @"AA"]; 31 | _tagsView.tagsArray = self.dataArray; 32 | _tagsView.allowEmptySelection = NO; 33 | _tagsView.contentInsets = UIEdgeInsetsMake(10, 10, 50, 10); 34 | } 35 | 36 | - (void)didReceiveMemoryWarning { 37 | [super didReceiveMemoryWarning]; 38 | // Dispose of any resources that can be recreated. 39 | } 40 | 41 | - (IBAction)add:(id)sender { 42 | NSString *tagName = self.tagNameTextField.text; 43 | if (tagName.length > 0) { 44 | [self.tagsView addTag:tagName]; 45 | } 46 | } 47 | 48 | - (IBAction)remove:(id)sender { 49 | if (self.indexTextField.text.length > 0) { 50 | NSInteger index = [self.indexTextField.text integerValue]; 51 | [self.tagsView removeTagAtIndex:index]; 52 | } 53 | } 54 | 55 | /* 56 | #pragma mark - Navigation 57 | 58 | // In a storyboard-based application, you will often want to do a little preparation before navigation 59 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 60 | // Get the new view controller using [segue destinationViewController]. 61 | // Pass the selected object to the new view controller. 62 | } 63 | */ 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /FMTagsView/Controller/FMHotSearchController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FMHotSearchController.h 3 | // FMTagsView 4 | // 5 | // Created by Subo on 16/5/27. 6 | // Copyright © 2016年 Followme. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //仿天猫热门搜索 12 | @interface FMHotSearchController : UIViewController 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /FMTagsView/Controller/FMHotSearchController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FMHotSearchController.m 3 | // FMTagsView 4 | // 5 | // Created by Subo on 16/5/27. 6 | // Copyright © 2016年 Followme. All rights reserved. 7 | // 8 | 9 | #import "FMHotSearchController.h" 10 | #import "FMTagsView.h" 11 | 12 | @interface FMHotSearchController () 13 | 14 | @property (weak, nonatomic) IBOutlet FMTagsView *tagsView; 15 | 16 | @property (strong, nonatomic) NSArray *dataArray; 17 | 18 | 19 | @end 20 | 21 | @implementation FMHotSearchController 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | 26 | _tagsView.contentInsets = UIEdgeInsetsZero; 27 | _tagsView.tagInsets = UIEdgeInsetsMake(5, 15, 5, 15); 28 | _tagsView.tagBorderWidth = 1; 29 | _tagsView.tagcornerRadius = 2; 30 | _tagsView.tagBorderColor = [UIColor lightGrayColor]; 31 | _tagsView.tagSelectedBorderColor = [UIColor lightGrayColor]; 32 | _tagsView.tagBackgroundColor = [UIColor whiteColor]; 33 | _tagsView.lineSpacing = 10; 34 | _tagsView.interitemSpacing = 10; 35 | _tagsView.tagFont = [UIFont systemFontOfSize:14]; 36 | _tagsView.tagTextColor = [UIColor grayColor]; 37 | _tagsView.tagSelectedBackgroundColor = _tagsView.tagBackgroundColor; 38 | _tagsView.tagSelectedTextColor = _tagsView.tagTextColor; 39 | 40 | _tagsView.delegate = self; 41 | 42 | self.dataArray = @[@"麻棉连衣裙", @"面条", @"亲子装", 43 | @"卫生巾", @"米", @"眉笔", @"蛋糕", 44 | @"面包", @"洗洁精", @"咖啡速溶", 45 | @"云南白药牙膏", @"方便面", @"空调"]; 46 | _tagsView.tagsArray = self.dataArray; 47 | } 48 | 49 | - (void)didReceiveMemoryWarning { 50 | [super didReceiveMemoryWarning]; 51 | 52 | } 53 | 54 | #pragma mark - ......::::::: FMTagsViewDelegate :::::::...... 55 | 56 | - (void)tagsView:(FMTagsView *)tagsView didSelectTagAtIndex:(NSUInteger)index { 57 | NSString *selectedKey = self.dataArray[index]; 58 | UIViewController *controller = [[UIViewController alloc] init]; 59 | controller.view.backgroundColor = [UIColor whiteColor]; 60 | controller.title = selectedKey; 61 | [self.navigationController pushViewController:controller animated:YES]; 62 | } 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /FMTagsView/Controller/MultipleSelectTestController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MultipleSelectTestController.h 3 | // FMTagsView 4 | // 5 | // Created by Subo on 2020/3/29. 6 | // Copyright © 2020 Followme. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | /// 多选测试 14 | @interface MultipleSelectTestController : UIViewController 15 | 16 | @end 17 | 18 | NS_ASSUME_NONNULL_END 19 | -------------------------------------------------------------------------------- /FMTagsView/Controller/MultipleSelectTestController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MultipleSelectTestController.m 3 | // FMTagsView 4 | // 5 | // Created by Subo on 2020/3/29. 6 | // Copyright © 2020 Followme. All rights reserved. 7 | // 8 | 9 | #import "MultipleSelectTestController.h" 10 | #import "FMTagsView.h" 11 | 12 | @interface MultipleSelectTestController () 13 | 14 | @property (weak, nonatomic) IBOutlet FMTagsView *tagsView; 15 | 16 | @property (strong, nonatomic) NSArray *dataArray; 17 | 18 | @end 19 | 20 | @implementation MultipleSelectTestController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | 25 | self.title = @"多选测试"; 26 | 27 | _tagsView.contentInsets = UIEdgeInsetsZero; 28 | _tagsView.tagInsets = UIEdgeInsetsMake(5, 15, 5, 15); 29 | _tagsView.tagBorderWidth = 1; 30 | _tagsView.tagcornerRadius = 2; 31 | _tagsView.tagBorderColor = [UIColor lightGrayColor]; 32 | _tagsView.tagSelectedBorderColor = [UIColor lightGrayColor]; 33 | _tagsView.tagBackgroundColor = [UIColor whiteColor]; 34 | _tagsView.lineSpacing = 10; 35 | _tagsView.interitemSpacing = 10; 36 | _tagsView.tagFont = [UIFont systemFontOfSize:14]; 37 | _tagsView.tagTextColor = [UIColor grayColor]; 38 | _tagsView.tagSelectedBackgroundColor = [UIColor orangeColor]; 39 | _tagsView.tagSelectedTextColor = _tagsView.tagTextColor; 40 | _tagsView.allowsMultipleSelection = YES; 41 | _tagsView.maximumNumberOfSelection = 5; //最多允许选择5个 42 | 43 | _tagsView.delegate = self; 44 | 45 | self.dataArray = @[@"麻棉连衣裙", @"面条", @"亲子装", 46 | @"卫生巾", @"米", @"眉笔", @"蛋糕", 47 | @"面包", @"洗洁精", @"咖啡速溶", 48 | @"云南白药牙膏", @"方便面", @"空调"]; 49 | _tagsView.tagsArray = self.dataArray; 50 | } 51 | 52 | #pragma mark - FMTagsViewDelegate 53 | - (void)tagsViewDidBeyondMaximumNumberOfSelection:(FMTagsView *)tagsView { 54 | NSLog(@"tagsViewDidBeyondMaximumNumberOfSelection:"); 55 | } 56 | 57 | - (void)tagsView:(FMTagsView *)tagsView didSelectTagAtIndex:(NSUInteger)index { 58 | NSLog(@"didSelectTagAtIndex: %ld", index); 59 | } 60 | 61 | - (void)tagsView:(FMTagsView *)tagsView didDeSelectTagAtIndex:(NSUInteger)index { 62 | NSLog(@"didDeSelectTagAtIndex: %ld", index); 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /FMTagsView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /FMTagsView/TagsView/FMTagsView.h: -------------------------------------------------------------------------------- 1 | // 2 | // FMTagsView.h 3 | // FollowmeiOS 4 | // 5 | // Created by Subo on 16/5/25. 6 | // Copyright © 2016年 com.followme. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol FMTagsViewDelegate; 12 | 13 | @interface FMTagCell : UICollectionViewCell 14 | 15 | @property (strong, nonatomic) UILabel *tagLabel; 16 | @property (nonatomic) UIEdgeInsets contentInsets; 17 | 18 | @end 19 | 20 | @interface FMTagsView : UIView 21 | 22 | @property (nonatomic) UIEdgeInsets contentInsets; // default is (10,10,10,10) 23 | 24 | @property (nonatomic) NSArray *tagsArray; // 数据源 25 | @property (weak, nonatomic) id delegate; 26 | 27 | @property (nonatomic) CGFloat lineSpacing; // 行间距, 默认为10 28 | @property (nonatomic) CGFloat interitemSpacing; // 元素之间的间距,默认为5 29 | 30 | #pragma mark - ......::::::: 标签定制属性 :::::::...... 31 | 32 | @property (nonatomic) UIEdgeInsets tagInsets; // default is (5,5,5,5) 33 | @property (nonatomic) CGFloat tagBorderWidth; // 标签边框宽度, default is 0 34 | @property (nonatomic) CGFloat tagcornerRadius; // default is 0 35 | @property (strong, nonatomic) UIColor *tagBorderColor; 36 | @property (strong, nonatomic) UIColor *tagSelectedBorderColor; 37 | @property (strong, nonatomic) UIColor *tagBackgroundColor; 38 | @property (strong, nonatomic) UIColor *tagSelectedBackgroundColor; 39 | @property (strong, nonatomic) UIFont *tagFont; 40 | @property (strong, nonatomic) UIFont *tagSelectedFont; 41 | @property (strong, nonatomic) UIColor *tagTextColor; 42 | @property (strong, nonatomic) UIColor *tagSelectedTextColor; 43 | 44 | @property (nonatomic) CGFloat tagHeight; // 标签高度,默认28 45 | @property (nonatomic) CGFloat mininumTagWidth; // tag 最小宽度值, 默认是0,即不作最小宽度限制 46 | @property (nonatomic) CGFloat maximumTagWidth; // tag 最大宽度值, 默认是CGFLOAT_MAX, 即不作最大宽度限制 47 | 48 | #pragma mark - ......::::::: 选中 :::::::...... 49 | 50 | @property (nonatomic) BOOL allowsSelection; // 是否允许选中, default is YES 51 | @property (nonatomic) BOOL allowsMultipleSelection; // 是否允许多选, default is NO 52 | @property (nonatomic) BOOL allowEmptySelection; // 是否允许空选, default is YES 53 | 54 | /** 55 | * 允许最多的选中个数,默认不作限制;该属性仅在 allowsMultipleSelection 为YES时有效 56 | */ 57 | @property (nonatomic) NSInteger maximumNumberOfSelection; 58 | 59 | @property (nonatomic, readonly) NSUInteger selectedIndex; // 选中索引 60 | @property (nonatomic, readonly) NSArray *selecedTags; // 多选状态下,选中的Tags 61 | @property (nonatomic, readonly) NSArray *selectedIndexes; // 多选状态下,选中的索引 62 | 63 | - (void)selectTagAtIndex:(NSUInteger)index animate:(BOOL)animate; 64 | - (void)deSelectTagAtIndex:(NSUInteger)index animate:(BOOL)animate; 65 | - (void)deSelectAll; 66 | 67 | - (FMTagCell *)cellForItemAtIndex:(NSInteger)index; 68 | 69 | #pragma mark - ......::::::: Edit :::::::...... 70 | 71 | // if not found, return NSNotFount 72 | - (NSUInteger)indexOfTag:(NSString *)tagName; 73 | 74 | - (void)addTag:(NSString *)tagName; 75 | - (void)insertTag:(NSString *)tagName AtIndex:(NSUInteger)index; 76 | 77 | - (void)removeTagWithName:(NSString *)tagName; 78 | - (void)removeTagAtIndex:(NSUInteger)index; 79 | - (void)removeAllTags; 80 | 81 | @end 82 | 83 | 84 | @protocol FMTagsViewDelegate 85 | 86 | @optional 87 | - (BOOL)tagsView:(FMTagsView *)tagsView shouldSelectTagAtIndex:(NSUInteger)index; 88 | - (void)tagsView:(FMTagsView *)tagsView didSelectTagAtIndex:(NSUInteger)index; 89 | 90 | - (BOOL)tagsView:(FMTagsView *)tagsView shouldDeselectItemAtIndex:(NSUInteger)index; 91 | - (void)tagsView:(FMTagsView *)tagsView didDeSelectTagAtIndex:(NSUInteger)index; 92 | 93 | // 超过最多选中个数,可在这个方法中做自定义提示,如提示用户超过最多选中项 94 | - (void)tagsViewDidBeyondMaximumNumberOfSelection:(FMTagsView *)tagsView; 95 | 96 | // 允许对Cell进行自定义操作 97 | - (void)tagsView:(FMTagsView *)tagsView willDispayCell:(FMTagCell *)tagCell atIndex:(NSUInteger)index; 98 | 99 | @end 100 | -------------------------------------------------------------------------------- /FMTagsView/TagsView/FMTagsView.m: -------------------------------------------------------------------------------- 1 | // 2 | // FMTagsView.m 3 | // FollowmeiOS 4 | // 5 | // Created by Subo on 16/5/25. 6 | // Copyright © 2016年 com.followme. All rights reserved. 7 | // 8 | 9 | #import "FMTagsView.h" 10 | 11 | static NSString * const kTagCellID = @"TagCellID"; 12 | 13 | @interface FMTagModel : NSObject 14 | 15 | @property (copy, nonnull) NSString *name; 16 | @property (nonatomic) BOOL selected; 17 | // 用于计算文字大小 18 | @property (strong, nonatomic) UIFont *font; 19 | 20 | @property (nonatomic, readonly) CGSize contentSize; 21 | 22 | - (instancetype)initWithName:(NSString *)name font:(UIFont *)font; 23 | 24 | @end 25 | 26 | @implementation FMTagModel 27 | 28 | - (instancetype)initWithName:(NSString *)name font:(UIFont *)font { 29 | if (self = [super init]) { 30 | _name = name; 31 | self.font = font; 32 | } 33 | return self; 34 | } 35 | 36 | - (void)setFont:(UIFont *)font { 37 | _font = font; 38 | 39 | [self calculateContentSize]; 40 | } 41 | 42 | - (void)calculateContentSize { 43 | NSDictionary *dict = @{NSFontAttributeName: self.font}; 44 | CGSize textSize = [_name boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, 1000) 45 | options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil].size; 46 | 47 | _contentSize = CGSizeMake(ceil(textSize.width), ceil(textSize.height)); 48 | } 49 | 50 | @end 51 | 52 | @interface FMTagCell () 53 | 54 | @property (nonatomic) FMTagModel *tagModel; 55 | 56 | @end 57 | 58 | @implementation FMTagCell 59 | 60 | - (instancetype)initWithFrame:(CGRect)frame { 61 | if (self = [super initWithFrame: frame]) { 62 | _tagLabel = [[UILabel alloc] init]; 63 | _tagLabel.textAlignment = NSTextAlignmentCenter; 64 | _tagLabel.userInteractionEnabled = NO; 65 | [self.contentView addSubview:_tagLabel]; 66 | } 67 | 68 | return self; 69 | } 70 | 71 | - (void)layoutSubviews { 72 | [super layoutSubviews]; 73 | 74 | CGRect bounds = self.contentView.bounds; 75 | CGFloat width = bounds.size.width - self.contentInsets.left - self.contentInsets.right; 76 | CGRect frame = CGRectMake(0, 0, width, [self.tagModel contentSize].height); 77 | self.tagLabel.frame = frame; 78 | self.tagLabel.center = self.contentView.center; 79 | } 80 | 81 | @end 82 | 83 | @interface FMEqualSpaceFlowLayout : UICollectionViewFlowLayout 84 | 85 | @property (weak, nonatomic) id delegate; 86 | @property (nonatomic, strong) NSMutableArray *itemAttributes; 87 | @property (assign,nonatomic) CGFloat contentHeight; 88 | 89 | @end 90 | 91 | @implementation FMEqualSpaceFlowLayout 92 | 93 | - (id)init 94 | { 95 | if (self = [super init]) { 96 | self.scrollDirection = UICollectionViewScrollDirectionVertical; 97 | self.minimumInteritemSpacing = 5; 98 | self.minimumLineSpacing = 5; 99 | self.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10); 100 | } 101 | 102 | return self; 103 | } 104 | 105 | - (CGFloat)minimumInteritemSpacingAtSection:(NSInteger)section { 106 | if ([self.delegate respondsToSelector:@selector(collectionView:layout:minimumInteritemSpacingForSectionAtIndex:)]) { 107 | return [self.delegate collectionView:self.collectionView layout:self minimumInteritemSpacingForSectionAtIndex:section]; 108 | } 109 | 110 | return self.minimumInteritemSpacing; 111 | } 112 | 113 | - (CGFloat)minimumLineSpacingAtSection:(NSInteger)section { 114 | if ([self.delegate respondsToSelector:@selector(collectionView:layout:minimumLineSpacingForSectionAtIndex:)]) { 115 | return [self.delegate collectionView:self.collectionView layout:self minimumLineSpacingForSectionAtIndex:section]; 116 | } 117 | 118 | return self.minimumLineSpacing; 119 | } 120 | 121 | - (UIEdgeInsets)sectionInsetAtSection:(NSInteger)section { 122 | if ([self.delegate respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)]) { 123 | return [self.delegate collectionView:self.collectionView layout:self insetForSectionAtIndex:section]; 124 | } 125 | 126 | return self.sectionInset; 127 | } 128 | 129 | #pragma mark - Methods to Override 130 | - (void)prepareLayout 131 | { 132 | [super prepareLayout]; 133 | 134 | _contentHeight = 0; 135 | NSInteger itemCount = [[self collectionView] numberOfItemsInSection:0]; 136 | self.itemAttributes = [NSMutableArray arrayWithCapacity:itemCount]; 137 | 138 | CGFloat minimumInteritemSpacing = [self minimumInteritemSpacingAtSection:0]; 139 | CGFloat minimumLineSpacing = [self minimumLineSpacingAtSection:0]; 140 | UIEdgeInsets sectionInset = [self sectionInsetAtSection:0]; 141 | 142 | CGFloat xOffset = sectionInset.left; 143 | CGFloat yOffset = sectionInset.top; 144 | CGFloat xNextOffset = sectionInset.left; 145 | CGRect colloctionViewBounds = [self collectionView].bounds; 146 | 147 | for (NSInteger idx = 0; idx < itemCount; idx++) { 148 | NSIndexPath *indexPath = [NSIndexPath indexPathForItem:idx inSection:0]; 149 | CGSize itemSize = [self.delegate collectionView:self.collectionView layout:self sizeForItemAtIndexPath:indexPath]; 150 | 151 | xNextOffset += (minimumInteritemSpacing + itemSize.width); 152 | 153 | if (xNextOffset - minimumInteritemSpacing > colloctionViewBounds.size.width - sectionInset.right) { 154 | xOffset = sectionInset.left; 155 | xNextOffset = (sectionInset.left + minimumInteritemSpacing + itemSize.width); 156 | yOffset += (itemSize.height + minimumLineSpacing); 157 | } 158 | else 159 | { 160 | xOffset = xNextOffset - (minimumInteritemSpacing + itemSize.width); 161 | } 162 | 163 | UICollectionViewLayoutAttributes *layoutAttributes = 164 | [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath]; 165 | 166 | layoutAttributes.frame = CGRectMake(xOffset, yOffset, itemSize.width, itemSize.height); 167 | [_itemAttributes addObject:layoutAttributes]; 168 | 169 | _contentHeight = MAX(_contentHeight, CGRectGetMaxY(layoutAttributes.frame)); 170 | } 171 | 172 | _contentHeight += sectionInset.bottom; 173 | } 174 | 175 | - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath 176 | { 177 | return (self.itemAttributes)[indexPath.item]; 178 | } 179 | 180 | - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect 181 | { 182 | return [self.itemAttributes filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(UICollectionViewLayoutAttributes *evaluatedObject, NSDictionary *bindings) { 183 | return CGRectIntersectsRect(rect, [evaluatedObject frame]); 184 | }]]; 185 | } 186 | 187 | - (CGSize)collectionViewContentSize { 188 | //重新计算布局 189 | [self prepareLayout]; 190 | 191 | CGSize contentSize = CGSizeMake(self.collectionView.frame.size.width, self.contentHeight); 192 | return contentSize; 193 | } 194 | 195 | - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds 196 | { 197 | CGRect oldBounds = self.collectionView.bounds; 198 | if (!CGSizeEqualToSize(oldBounds.size, newBounds.size)) { 199 | return YES; 200 | } 201 | return NO; 202 | } 203 | 204 | @end 205 | 206 | @interface FMTagsView () 207 | 208 | @property (strong, nonatomic) UICollectionView *collectionView; 209 | @property (strong, nonatomic) NSMutableArray *tagsMutableArray; 210 | @property (strong, nonatomic) NSMutableArray *tagModels; 211 | 212 | @end 213 | 214 | @implementation FMTagsView 215 | 216 | - (instancetype)initWithFrame:(CGRect)frame 217 | { 218 | self = [super initWithFrame:frame]; 219 | if (self) { 220 | [self commonInit]; 221 | } 222 | return self; 223 | } 224 | 225 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 226 | if (self = [super initWithCoder:aDecoder]) { 227 | [self commonInit]; 228 | } 229 | 230 | return self; 231 | } 232 | 233 | - (void)commonInit { 234 | self.backgroundColor = [UIColor whiteColor]; 235 | _contentInsets = UIEdgeInsetsMake(10, 10, 10, 10); 236 | _tagInsets = UIEdgeInsetsMake(5, 10, 5, 10); 237 | _tagBorderWidth = 0; 238 | _tagBackgroundColor = [UIColor colorWithRed:0.94 green:0.94 blue:0.94 alpha:1.0]; 239 | _tagSelectedBackgroundColor = [UIColor colorWithRed:1.0 green:0.38 blue:0.0 alpha:1.0]; 240 | _tagFont = [UIFont systemFontOfSize:14]; 241 | _tagSelectedFont = [UIFont systemFontOfSize:14]; 242 | _tagTextColor = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:1.0]; 243 | _tagSelectedTextColor = [UIColor whiteColor]; 244 | 245 | _tagHeight = 28; 246 | _mininumTagWidth = 0; 247 | _maximumTagWidth = CGFLOAT_MAX; 248 | _lineSpacing = 10; 249 | _interitemSpacing = 5; 250 | 251 | _allowsSelection = YES; 252 | _allowsMultipleSelection = NO; 253 | _allowEmptySelection = YES; 254 | _maximumNumberOfSelection = NSIntegerMax; 255 | 256 | [self addSubview:self.collectionView]; 257 | 258 | UICollectionView *collectionView = self.collectionView; 259 | collectionView.translatesAutoresizingMaskIntoConstraints = NO; 260 | NSDictionary *views = NSDictionaryOfVariableBindings(collectionView); 261 | NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[collectionView]|" 262 | options:NSLayoutFormatAlignAllTop 263 | metrics:nil 264 | views:views]; 265 | constraints = [constraints arrayByAddingObjectsFromArray: 266 | [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[collectionView]|" 267 | options:0 268 | metrics:nil 269 | views:views]]; 270 | [self addConstraints:constraints]; 271 | } 272 | 273 | - (CGSize)intrinsicContentSize { 274 | CGSize contentSize = self.collectionView.collectionViewLayout.collectionViewContentSize; 275 | return CGSizeMake(UIViewNoIntrinsicMetric, contentSize.height); 276 | } 277 | 278 | - (void)setTagsArray:(NSArray *)tagsArray { 279 | _tagsMutableArray = [tagsArray mutableCopy]; 280 | [self.tagModels removeAllObjects]; 281 | [tagsArray enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 282 | FMTagModel *tagModel = [[FMTagModel alloc] initWithName:obj font:self.tagFont]; 283 | [self.tagModels addObject:tagModel]; 284 | }]; 285 | [self.collectionView reloadData]; 286 | [self invalidateIntrinsicContentSize]; 287 | } 288 | 289 | - (void)selectTagAtIndex:(NSUInteger)index animate:(BOOL)animate { 290 | if (index >= self.tagModels.count || !self.allowsSelection) { 291 | return; 292 | } 293 | 294 | if (self.allowsSelection && !self.allowsMultipleSelection) { 295 | [self deSelectAll]; 296 | } 297 | 298 | [self.collectionView selectItemAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0] 299 | animated:animate 300 | scrollPosition:UICollectionViewScrollPositionNone]; 301 | [self collectionView:self.collectionView didSelectItemAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]]; 302 | } 303 | 304 | - (void)deSelectTagAtIndex:(NSUInteger)index animate:(BOOL)animate { 305 | if (index >= self.tagModels.count) { 306 | return; 307 | } 308 | [self collectionView:self.collectionView didDeselectItemAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]]; 309 | } 310 | 311 | - (void)deSelectAll { 312 | for (NSIndexPath *indexPath in self.collectionView.indexPathsForSelectedItems) { 313 | FMTagModel *tagModel = self.tagModels[indexPath.row]; 314 | tagModel.selected = NO; 315 | [self.collectionView deselectItemAtIndexPath:indexPath animated:YES]; 316 | } 317 | [self.collectionView reloadData]; 318 | } 319 | 320 | - (FMTagCell *)cellForItemAtIndex:(NSInteger)index { 321 | NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0]; 322 | return (FMTagCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; 323 | } 324 | 325 | #pragma mark - ......::::::: Edit :::::::...... 326 | 327 | - (NSUInteger)indexOfTag:(NSString *)tagName { 328 | __block NSUInteger index = NSNotFound; 329 | [self.tagsMutableArray enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 330 | if ([obj isEqualToString:tagName]) { 331 | index = idx; 332 | *stop = YES; 333 | } 334 | }]; 335 | 336 | return index; 337 | } 338 | 339 | - (void)addTag:(NSString *)tagName { 340 | [self.tagsMutableArray addObject:tagName]; 341 | FMTagModel *tagModel = [[FMTagModel alloc] initWithName:tagName font:self.tagFont]; 342 | [self.tagModels addObject:tagModel]; 343 | [self.collectionView reloadData]; 344 | [self invalidateIntrinsicContentSize]; 345 | } 346 | 347 | - (void)insertTag:(NSString *)tagName AtIndex:(NSUInteger)index { 348 | if (index >= self.tagsMutableArray.count) { 349 | return; 350 | } 351 | 352 | [self.tagsMutableArray insertObject:tagName atIndex:index]; 353 | FMTagModel *tagModel = [[FMTagModel alloc] initWithName:tagName font:self.tagFont]; 354 | [self.tagModels insertObject:tagModel atIndex:index]; 355 | [self.collectionView reloadData]; 356 | [self invalidateIntrinsicContentSize]; 357 | } 358 | 359 | - (void)removeTagWithName:(NSString *)tagName { 360 | return [self removeTagAtIndex:[self indexOfTag:tagName]]; 361 | } 362 | 363 | - (void)removeTagAtIndex:(NSUInteger)index { 364 | if (index >= self.tagsMutableArray.count || index == NSNotFound) { 365 | return ; 366 | } 367 | 368 | [self.tagsMutableArray removeObjectAtIndex:index]; 369 | [self.tagModels removeObjectAtIndex:index]; 370 | [self.collectionView reloadData]; 371 | [self invalidateIntrinsicContentSize]; 372 | } 373 | 374 | - (void)removeAllTags { 375 | [self.tagsMutableArray removeAllObjects]; 376 | [self.tagModels removeAllObjects]; 377 | [self.collectionView reloadData]; 378 | } 379 | 380 | #pragma mark - ......::::::: CollectionView DataSource :::::::...... 381 | 382 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 383 | return self.tagModels.count; 384 | } 385 | 386 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 387 | FMTagCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kTagCellID forIndexPath:indexPath]; 388 | 389 | FMTagModel *tagModel = self.tagModels[indexPath.row]; 390 | cell.tagModel = tagModel; 391 | cell.tagLabel.text = tagModel.name; 392 | cell.contentInsets = self.tagInsets; 393 | cell.layer.cornerRadius = self.tagcornerRadius; 394 | cell.layer.borderWidth = self.tagBorderWidth; 395 | cell.layer.masksToBounds = self.tagcornerRadius > 0; 396 | [self setCell:cell selected:tagModel.selected]; 397 | 398 | return cell; 399 | } 400 | 401 | - (void)setCell:(FMTagCell *)cell selected:(BOOL)selected { 402 | 403 | if (selected) { 404 | cell.backgroundColor = self.tagSelectedBackgroundColor; 405 | cell.tagLabel.font = self.tagSelectedFont; 406 | cell.tagLabel.textColor = self.tagSelectedTextColor; 407 | cell.layer.borderColor = self.tagSelectedBorderColor.CGColor; 408 | }else { 409 | cell.backgroundColor = self.tagBackgroundColor; 410 | cell.tagLabel.font = self.tagFont; 411 | cell.tagLabel.textColor = self.tagTextColor; 412 | cell.layer.borderColor = self.tagBorderColor.CGColor; 413 | } 414 | [cell setSelected:selected]; 415 | } 416 | 417 | #pragma mark - ......::::::: UICollectionViewDelegate :::::::...... 418 | 419 | - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath { 420 | FMTagCell *tagCell = (FMTagCell *)cell; 421 | if ([self.delegate respondsToSelector:@selector(tagsView:willDispayCell:atIndex:)]) { 422 | [self.delegate tagsView:self willDispayCell:tagCell atIndex:indexPath.row]; 423 | } 424 | } 425 | 426 | - (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath { 427 | return YES; 428 | } 429 | 430 | - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath { 431 | if ([self.delegate respondsToSelector:@selector(tagsView:shouldSelectTagAtIndex:)]) { 432 | return [self.delegate tagsView:self shouldSelectTagAtIndex:indexPath.row]; 433 | } 434 | 435 | return _allowsSelection; 436 | } 437 | 438 | - (BOOL)collectionView:(UICollectionView *)collectionView shouldDeselectItemAtIndexPath:(NSIndexPath *)indexPath { 439 | if ([self.delegate respondsToSelector:@selector(tagsView:shouldDeselectItemAtIndex:)]) { 440 | return [self.delegate tagsView:self shouldDeselectItemAtIndex:indexPath.row]; 441 | } 442 | return YES; 443 | } 444 | 445 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { 446 | 447 | FMTagModel *tagModel = self.tagModels[indexPath.row]; 448 | FMTagCell *cell = (FMTagCell *)[collectionView cellForItemAtIndexPath:indexPath]; 449 | if (self.allowsMultipleSelection) { 450 | 451 | if (self.collectionView.indexPathsForSelectedItems.count > self.maximumNumberOfSelection) { 452 | tagModel.selected = NO; 453 | [self setCell:cell selected:NO]; 454 | [collectionView reloadItemsAtIndexPaths:@[indexPath]]; 455 | if ([self.delegate respondsToSelector:@selector(tagsViewDidBeyondMaximumNumberOfSelection:)]) { 456 | [self.delegate tagsViewDidBeyondMaximumNumberOfSelection:self]; 457 | } 458 | return; 459 | } 460 | 461 | tagModel.selected = YES; 462 | [self setCell:cell selected:YES]; 463 | [self notifyDidSelectTagAtIndex:indexPath.item]; 464 | return; 465 | } 466 | 467 | //修复单选情况下,无法取消选中的问题 468 | if (tagModel.selected) { 469 | //不允许空选,直接返回 470 | if (!self.allowEmptySelection && self.collectionView.indexPathsForSelectedItems.count == 1) { 471 | return; 472 | } 473 | 474 | cell.selected = NO; 475 | collectionView.allowsMultipleSelection = YES; 476 | [collectionView deselectItemAtIndexPath:indexPath animated:NO]; 477 | [self collectionView:collectionView didDeselectItemAtIndexPath:indexPath]; 478 | collectionView.allowsMultipleSelection = NO; 479 | return; 480 | } 481 | 482 | tagModel.selected = YES; 483 | [self setCell:cell selected:YES]; 484 | [self notifyDidSelectTagAtIndex:indexPath.item]; 485 | } 486 | 487 | - (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath { 488 | 489 | FMTagModel *tagModel = self.tagModels[indexPath.row]; 490 | FMTagCell *cell = (FMTagCell *)[collectionView cellForItemAtIndexPath:indexPath]; 491 | tagModel.selected = NO; 492 | [self setCell:cell selected:NO]; 493 | 494 | if ([self.delegate respondsToSelector:@selector(tagsView:didDeSelectTagAtIndex:)]) { 495 | [self.delegate tagsView:self didDeSelectTagAtIndex:indexPath.item]; 496 | } 497 | } 498 | 499 | #pragma mark - ......::::::: UICollectionViewDelegateFlowLayout :::::::...... 500 | 501 | - (CGSize)collectionView:(UICollectionView *)collectionView 502 | layout:(UICollectionViewLayout*)collectionViewLayout 503 | sizeForItemAtIndexPath:(NSIndexPath *)indexPath { 504 | FMTagModel *tagModel = self.tagModels[indexPath.row]; 505 | 506 | CGFloat width = tagModel.contentSize.width + self.tagInsets.left + self.tagInsets.right; 507 | if (width < self.mininumTagWidth) { 508 | width = self.mininumTagWidth; 509 | } 510 | if (width > self.maximumTagWidth) { 511 | width = self.maximumTagWidth; 512 | } 513 | 514 | return CGSizeMake(width, self.tagHeight); 515 | } 516 | 517 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { 518 | return self.interitemSpacing; 519 | } 520 | 521 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { 522 | return self.lineSpacing; 523 | } 524 | 525 | - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { 526 | return self.contentInsets; 527 | } 528 | 529 | #pragma mark - ......::::::: Private Methods :::::::...... 530 | 531 | - (void)notifyDidSelectTagAtIndex:(NSInteger)index { 532 | if ([self.delegate respondsToSelector:@selector(tagsView:didSelectTagAtIndex:)]) { 533 | [self.delegate tagsView:self didSelectTagAtIndex:index]; 534 | } 535 | } 536 | 537 | #pragma mark - ......::::::: Getter and Setter :::::::...... 538 | 539 | - (UICollectionView *)collectionView { 540 | if (!_collectionView) { 541 | FMEqualSpaceFlowLayout *flowLayout = [[FMEqualSpaceFlowLayout alloc] init]; 542 | flowLayout.delegate = self; 543 | _collectionView = [[UICollectionView alloc] initWithFrame:self.bounds collectionViewLayout:flowLayout]; 544 | _collectionView.backgroundColor = [UIColor clearColor]; 545 | [_collectionView registerClass:[FMTagCell class] forCellWithReuseIdentifier:kTagCellID]; 546 | _collectionView.dataSource = self; 547 | _collectionView.delegate = self; 548 | } 549 | 550 | _collectionView.allowsSelection = _allowsSelection; 551 | _collectionView.allowsMultipleSelection = _allowsMultipleSelection; 552 | 553 | return _collectionView; 554 | } 555 | 556 | - (UIFont *)tagSelectedFont { 557 | if (!_tagSelectedFont) { 558 | return _tagFont; 559 | } 560 | 561 | return _tagSelectedFont; 562 | } 563 | 564 | - (UIColor *)tagSelectedBorderColor { 565 | if (!_tagSelectedBorderColor) { 566 | return _tagBorderColor; 567 | } 568 | 569 | return _tagSelectedBorderColor; 570 | } 571 | 572 | - (NSUInteger)selectedIndex { 573 | return self.collectionView.indexPathsForSelectedItems.firstObject.row; 574 | } 575 | 576 | - (NSArray *)selecedTags { 577 | // if (!self.allowsMultipleSelection) { 578 | // return nil; 579 | // } 580 | NSMutableArray *result = [[NSMutableArray alloc] init]; 581 | 582 | for (NSIndexPath *indexPath in self.collectionView.indexPathsForSelectedItems) { 583 | [result addObject:self.tagsMutableArray[indexPath.row]]; 584 | } 585 | 586 | return result.copy; 587 | } 588 | 589 | - (NSArray *)selectedIndexes { 590 | // if (!self.allowsMultipleSelection) { 591 | // return nil; 592 | // } 593 | 594 | NSMutableArray *result = [[NSMutableArray alloc] init]; 595 | 596 | for (NSIndexPath *indexPath in self.collectionView.indexPathsForSelectedItems) { 597 | [result addObject:@(indexPath.row)]; 598 | } 599 | 600 | return result.copy; 601 | } 602 | 603 | - (NSMutableArray *)tagModels { 604 | if (!_tagModels) { 605 | _tagModels = [[NSMutableArray alloc] init]; 606 | } 607 | return _tagModels; 608 | } 609 | 610 | - (NSArray *)tagsArray { 611 | return [self.tagsMutableArray copy]; 612 | } 613 | 614 | @end 615 | -------------------------------------------------------------------------------- /FMTagsView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // FMTagsView 4 | // 5 | // Created by Subo on 16/5/25. 6 | // Copyright © 2016年 Followme. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /FMTagsView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // FMTagsView 4 | // 5 | // Created by Subo on 16/5/25. 6 | // Copyright © 2016年 Followme. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "CustomerViewController.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | } 21 | 22 | 23 | - (void)didReceiveMemoryWarning { 24 | [super didReceiveMemoryWarning]; 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | - (IBAction)showCustomerController:(id)sender { 29 | CustomerViewController *customerVC = [[CustomerViewController alloc] init]; 30 | [self.navigationController pushViewController:customerVC animated:YES]; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /FMTagsView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // FMTagsView 4 | // 5 | // Created by Subo on 16/5/25. 6 | // Copyright © 2016年 Followme. 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 | -------------------------------------------------------------------------------- /FMTagsViewTests/FMTagsViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // FMTagsViewTests.m 3 | // FMTagsViewTests 4 | // 5 | // Created by Subo on 16/5/25. 6 | // Copyright © 2016年 Followme. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FMTagsViewTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation FMTagsViewTests 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 | -------------------------------------------------------------------------------- /FMTagsViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /FMTagsViewUITests/FMTagsViewUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // FMTagsViewUITests.m 3 | // FMTagsViewUITests 4 | // 5 | // Created by Subo on 16/5/25. 6 | // Copyright © 2016年 Followme. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FMTagsViewUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation FMTagsViewUITests 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 | -------------------------------------------------------------------------------- /FMTagsViewUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 SUBO <455295813@qq.com> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | source 'https://cdn.cocoapods.org/' 2 | platform :ios, '8.0' 3 | 4 | target "FMTagsView" do 5 | pod 'Masonry' 6 | end -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.0.0) 3 | 4 | DEPENDENCIES: 5 | - Masonry 6 | 7 | SPEC REPOS: 8 | trunk: 9 | - Masonry 10 | 11 | SPEC CHECKSUMS: 12 | Masonry: b529bb169217897b6354d4b56b1fada6d475b13d 13 | 14 | PODFILE CHECKSUM: 655a1948f909ab34c634fc4efe02916c1b9e0c5c 15 | 16 | COCOAPODS: 1.12.1 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FMTagsView 2 | 3 | [![LICENSE](https://img.shields.io/cocoapods/l/FMTagsView)](https://github.com/lexiaoyao20/FMTagsView/blob/master/LICENSE) 4 | [![Version](https://img.shields.io/cocoapods/v/FMTagsView.svg)](https://img.shields.io/cocoapods/v/FMTagsView.svg) 5 | [![CocoaPods](https://img.shields.io/badge/platform-iOS7.0+-yellowgreen)](https://cocoapods.org/pods/FMTagsView) 6 | 7 | 8 | 一个基于UICollectionView的标签展示控件 9 | 10 | ## Screenshots 11 | 1. 示例一,仿天猫热门搜索标签的效果: 12 | ![Hot Search.gif](https://github.com/lexiaoyao20/FMTagsView/blob/master/Screenshots/aaaa.gif) 13 | 14 | 2. 实例二,动态添加和删除标签 15 | 16 | ![动态添加和删除.gif](https://github.com/lexiaoyao20/FMTagsView/blob/master/Screenshots/bbb.gif) 17 | 18 | 19 | ## Features 20 | * 支持AutoLayout 21 | * 支持自定义Tag的外观,如圆角,背景颜色,标签文字颜色... 22 | * 支持动态添加和删除Tag 23 | * 支持单选和多选模式 24 | 25 | ## How to Use 26 | 27 | 首先,添加 FMTagsView.h 和 FMTagsView.m 这两个文件到你项目中,或者使用pod来安装。 28 | ``` 29 | pod 'FMTagsView' 30 | ``` 31 | 32 | 控件初始化示例: 33 | ``` 34 | FMTagsView *tagsView = [[FMTagsView alloc] initWithFrame:CGRectMake(10, 120, 300, 150)]; 35 | tagsView.contentInsets = UIEdgeInsetsZero; 36 | tagsView.tagInsets = UIEdgeInsetsMake(5, 15, 5, 15); 37 | tagsView.tagBorderWidth = 1; 38 | tagsView.tagcornerRadius = 2; 39 | tagsView.tagBorderColor = [UIColor lightGrayColor]; 40 | tagsView.tagSelectedBorderColor = [UIColor lightGrayColor]; 41 | tagsView.tagBackgroundColor = [UIColor whiteColor]; 42 | tagsView.lineSpacing = 10; 43 | tagsView.interitemSpacing = 10; 44 | tagsView.tagFont = [UIFont systemFontOfSize:14]; 45 | tagsView.tagTextColor = [UIColor grayColor]; 46 | tagsView.delegate = self; 47 | [self.view addSubview:tagsView]; 48 | 49 | NSArray *dataArray = @[@"麻棉连衣裙", @"面条", @"亲子装", 50 | @"卫生巾", @"米", @"眉笔", @"蛋糕", 51 | @"面包", @"洗洁精", @"咖啡速溶", 52 | @"云南白药牙膏", @"方便面", @"空调"]; 53 | //设置数据源 54 | tagsView.tagsArray = dataArray; 55 | ``` 56 | 实现代理方法: 57 | ``` 58 | //点击标签处理逻辑 59 | - (void)tagsView:(FMTagsView *)tagsView didSelectTagAtIndex:(NSUInteger)index { 60 | NSString *selectedKey = self.dataArray[index]; 61 | UIViewController *controller = [[UIViewController alloc] init]; 62 | controller.view.backgroundColor = [UIColor whiteColor]; 63 | controller.title = selectedKey; 64 | [self.navigationController pushViewController:controller animated:YES]; 65 | } 66 | ``` 67 | -------------------------------------------------------------------------------- /Screenshots/aaaa.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lexiaoyao20/FMTagsView/5fddb0e9f3f66820eb7027c5991a0ff529048aac/Screenshots/aaaa.gif -------------------------------------------------------------------------------- /Screenshots/bbb.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lexiaoyao20/FMTagsView/5fddb0e9f3f66820eb7027c5991a0ff529048aac/Screenshots/bbb.gif --------------------------------------------------------------------------------