├── .gitignore ├── CXProvincesMapView.podspec ├── CXProvincesMapView.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ ├── IDEWorkspaceChecks.plist │ └── WorkspaceSettings.xcsettings ├── CXProvincesMapView ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── pin.imageset │ │ ├── Contents.json │ │ ├── pin.png │ │ ├── pin@2x.png │ │ └── pin@3x.png │ └── push_pin.imageset │ │ ├── Contents.json │ │ ├── push_pin_14.406477732794px_1206217_easyicon.net.png │ │ ├── push_pin_14.406477732794px_1206217_easyicon.net@2x.png │ │ └── push_pin_14.406477732794px_1206217_easyicon.net@3x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CXProvincesMapView │ ├── CXProvincesMapView.h │ ├── CXProvincesMapView.m │ ├── ChinaMapPath.h │ ├── ChinaMapPath.m │ ├── ChinaMapView.h │ └── ChinaMapView.m ├── Fujian.h ├── Fujian.m ├── FujianMapController.h ├── FujianMapController.m ├── FujianMapPath.h ├── FujianMapPath.m ├── Info.plist ├── SampleMapController.h ├── SampleMapController.m ├── StyleKitName.h ├── StyleKitName.m ├── SwiftLaunchView.h ├── SwiftLaunchView.m ├── ViewController.h ├── ViewController.m └── main.m ├── LICENSE ├── README.md └── gif └── province.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots/**/*.png 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /CXProvincesMapView.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint CXProvincesMapView.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |spec| 10 | 11 | spec.name = "CXProvincesMapView" 12 | spec.version = "0.1.0" 13 | spec.summary = "CXProvincesMapView 是一个显示中国省份的地图控件" 14 | 15 | spec.description = <<-DESC 16 | CXProvincesMapView 是一个显示中国省份的地图控件,支持点击效果的设置. 17 | DESC 18 | 19 | spec.homepage = "https://github.com/CXTretar/CXProvincesMapView" 20 | 21 | spec.license = "MIT" 22 | 23 | spec.author = { "CXTretar" => "misscxuan@163.com" } 24 | spec.platform = :ios, "8.0" 25 | spec.source = { :git => 'https://github.com/CXTretar/CXProvincesMapView.git', :tag => spec.version.to_s } 26 | 27 | spec.source_files = "CXProvincesMapView/CXProvincesMapView/*.{h,m}" 28 | spec.requires_arc = true 29 | 30 | end 31 | -------------------------------------------------------------------------------- /CXProvincesMapView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CA694867235EC48A0088197C /* FujianMapPath.m in Sources */ = {isa = PBXBuildFile; fileRef = CA694866235EC48A0088197C /* FujianMapPath.m */; }; 11 | CA69486A235EFCE10088197C /* Fujian.m in Sources */ = {isa = PBXBuildFile; fileRef = CA694869235EFCE10088197C /* Fujian.m */; }; 12 | CA69486D235EFF5F0088197C /* FujianMapController.m in Sources */ = {isa = PBXBuildFile; fileRef = CA69486C235EFF5F0088197C /* FujianMapController.m */; }; 13 | CAE5647623538540003CBD3F /* CXProvincesMapView.m in Sources */ = {isa = PBXBuildFile; fileRef = CAE5647323538540003CBD3F /* CXProvincesMapView.m */; }; 14 | CAE5647B23538FBE003CBD3F /* ChinaMapPath.m in Sources */ = {isa = PBXBuildFile; fileRef = CAE5647723538FBE003CBD3F /* ChinaMapPath.m */; }; 15 | CAE5647C23538FBE003CBD3F /* ChinaMapView.m in Sources */ = {isa = PBXBuildFile; fileRef = CAE5647A23538FBE003CBD3F /* ChinaMapView.m */; }; 16 | DC5D89D6226B725700F16B77 /* SwiftLaunchView.m in Sources */ = {isa = PBXBuildFile; fileRef = DC5D89D5226B725700F16B77 /* SwiftLaunchView.m */; }; 17 | DC70E7E82264E0D000BBC128 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DC70E7E72264E0D000BBC128 /* AppDelegate.m */; }; 18 | DC70E7EB2264E0D000BBC128 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DC70E7EA2264E0D000BBC128 /* ViewController.m */; }; 19 | DC70E7EE2264E0D000BBC128 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC70E7EC2264E0D000BBC128 /* Main.storyboard */; }; 20 | DC70E7F02264E0D100BBC128 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC70E7EF2264E0D100BBC128 /* Assets.xcassets */; }; 21 | DC70E7F32264E0D100BBC128 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC70E7F12264E0D100BBC128 /* LaunchScreen.storyboard */; }; 22 | DC70E7F62264E0D100BBC128 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DC70E7F52264E0D100BBC128 /* main.m */; }; 23 | DCAE735B227756AF002C1B7F /* StyleKitName.m in Sources */ = {isa = PBXBuildFile; fileRef = DCAE7359227756AF002C1B7F /* StyleKitName.m */; }; 24 | DCE8380F226E15310067AC93 /* SampleMapController.m in Sources */ = {isa = PBXBuildFile; fileRef = DCE8380E226E15310067AC93 /* SampleMapController.m */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | CA694865235EC48A0088197C /* FujianMapPath.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FujianMapPath.h; sourceTree = ""; }; 29 | CA694866235EC48A0088197C /* FujianMapPath.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FujianMapPath.m; sourceTree = ""; }; 30 | CA694868235EFCE00088197C /* Fujian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Fujian.h; sourceTree = ""; }; 31 | CA694869235EFCE10088197C /* Fujian.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Fujian.m; sourceTree = ""; }; 32 | CA69486B235EFF5F0088197C /* FujianMapController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FujianMapController.h; sourceTree = ""; }; 33 | CA69486C235EFF5F0088197C /* FujianMapController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FujianMapController.m; sourceTree = ""; }; 34 | CAE5647223538540003CBD3F /* CXProvincesMapView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CXProvincesMapView.h; sourceTree = ""; }; 35 | CAE5647323538540003CBD3F /* CXProvincesMapView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CXProvincesMapView.m; sourceTree = ""; }; 36 | CAE5647723538FBE003CBD3F /* ChinaMapPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChinaMapPath.m; sourceTree = ""; }; 37 | CAE5647823538FBE003CBD3F /* ChinaMapPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChinaMapPath.h; sourceTree = ""; }; 38 | CAE5647923538FBE003CBD3F /* ChinaMapView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChinaMapView.h; sourceTree = ""; }; 39 | CAE5647A23538FBE003CBD3F /* ChinaMapView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChinaMapView.m; sourceTree = ""; }; 40 | DC5D89D4226B725700F16B77 /* SwiftLaunchView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftLaunchView.h; sourceTree = ""; }; 41 | DC5D89D5226B725700F16B77 /* SwiftLaunchView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SwiftLaunchView.m; sourceTree = ""; }; 42 | DC70E7E32264E0D000BBC128 /* CXProvincesMapView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CXProvincesMapView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | DC70E7E62264E0D000BBC128 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 44 | DC70E7E72264E0D000BBC128 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 45 | DC70E7E92264E0D000BBC128 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 46 | DC70E7EA2264E0D000BBC128 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 47 | DC70E7ED2264E0D000BBC128 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 48 | DC70E7EF2264E0D100BBC128 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 49 | DC70E7F22264E0D100BBC128 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 50 | DC70E7F42264E0D100BBC128 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | DC70E7F52264E0D100BBC128 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 52 | DCAE7359227756AF002C1B7F /* StyleKitName.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StyleKitName.m; sourceTree = ""; }; 53 | DCAE735A227756AF002C1B7F /* StyleKitName.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleKitName.h; sourceTree = ""; }; 54 | DCE8380D226E15310067AC93 /* SampleMapController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SampleMapController.h; sourceTree = ""; }; 55 | DCE8380E226E15310067AC93 /* SampleMapController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SampleMapController.m; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | DC70E7E02264E0D000BBC128 /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | CAE5646C23538540003CBD3F /* CXProvincesMapView */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | CAE5647823538FBE003CBD3F /* ChinaMapPath.h */, 73 | CAE5647723538FBE003CBD3F /* ChinaMapPath.m */, 74 | CAE5647923538FBE003CBD3F /* ChinaMapView.h */, 75 | CAE5647A23538FBE003CBD3F /* ChinaMapView.m */, 76 | CAE5647223538540003CBD3F /* CXProvincesMapView.h */, 77 | CAE5647323538540003CBD3F /* CXProvincesMapView.m */, 78 | ); 79 | path = CXProvincesMapView; 80 | sourceTree = ""; 81 | }; 82 | DC70E7DA2264E0D000BBC128 = { 83 | isa = PBXGroup; 84 | children = ( 85 | DC70E7E52264E0D000BBC128 /* CXProvincesMapView */, 86 | DC70E7E42264E0D000BBC128 /* Products */, 87 | ); 88 | sourceTree = ""; 89 | }; 90 | DC70E7E42264E0D000BBC128 /* Products */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | DC70E7E32264E0D000BBC128 /* CXProvincesMapView.app */, 94 | ); 95 | name = Products; 96 | sourceTree = ""; 97 | }; 98 | DC70E7E52264E0D000BBC128 /* CXProvincesMapView */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | CAE5646C23538540003CBD3F /* CXProvincesMapView */, 102 | DCAE735A227756AF002C1B7F /* StyleKitName.h */, 103 | DCAE7359227756AF002C1B7F /* StyleKitName.m */, 104 | CA694868235EFCE00088197C /* Fujian.h */, 105 | CA694869235EFCE10088197C /* Fujian.m */, 106 | CA694865235EC48A0088197C /* FujianMapPath.h */, 107 | CA694866235EC48A0088197C /* FujianMapPath.m */, 108 | DCE8380D226E15310067AC93 /* SampleMapController.h */, 109 | DCE8380E226E15310067AC93 /* SampleMapController.m */, 110 | CA69486B235EFF5F0088197C /* FujianMapController.h */, 111 | CA69486C235EFF5F0088197C /* FujianMapController.m */, 112 | DC70E7E62264E0D000BBC128 /* AppDelegate.h */, 113 | DC70E7E72264E0D000BBC128 /* AppDelegate.m */, 114 | DC70E7E92264E0D000BBC128 /* ViewController.h */, 115 | DC70E7EA2264E0D000BBC128 /* ViewController.m */, 116 | DC5D89D4226B725700F16B77 /* SwiftLaunchView.h */, 117 | DC5D89D5226B725700F16B77 /* SwiftLaunchView.m */, 118 | DC70E7EC2264E0D000BBC128 /* Main.storyboard */, 119 | DC70E7EF2264E0D100BBC128 /* Assets.xcassets */, 120 | DC70E7F12264E0D100BBC128 /* LaunchScreen.storyboard */, 121 | DC70E7F42264E0D100BBC128 /* Info.plist */, 122 | DC70E7F52264E0D100BBC128 /* main.m */, 123 | ); 124 | path = CXProvincesMapView; 125 | sourceTree = ""; 126 | }; 127 | /* End PBXGroup section */ 128 | 129 | /* Begin PBXNativeTarget section */ 130 | DC70E7E22264E0D000BBC128 /* CXProvincesMapView */ = { 131 | isa = PBXNativeTarget; 132 | buildConfigurationList = DC70E7F92264E0D100BBC128 /* Build configuration list for PBXNativeTarget "CXProvincesMapView" */; 133 | buildPhases = ( 134 | DC70E7DF2264E0D000BBC128 /* Sources */, 135 | DC70E7E02264E0D000BBC128 /* Frameworks */, 136 | DC70E7E12264E0D000BBC128 /* Resources */, 137 | ); 138 | buildRules = ( 139 | ); 140 | dependencies = ( 141 | ); 142 | name = CXProvincesMapView; 143 | productName = CXProvincesMapView; 144 | productReference = DC70E7E32264E0D000BBC128 /* CXProvincesMapView.app */; 145 | productType = "com.apple.product-type.application"; 146 | }; 147 | /* End PBXNativeTarget section */ 148 | 149 | /* Begin PBXProject section */ 150 | DC70E7DB2264E0D000BBC128 /* Project object */ = { 151 | isa = PBXProject; 152 | attributes = { 153 | LastUpgradeCheck = 1020; 154 | ORGANIZATIONNAME = CXTretar; 155 | TargetAttributes = { 156 | DC70E7E22264E0D000BBC128 = { 157 | CreatedOnToolsVersion = 10.2; 158 | }; 159 | }; 160 | }; 161 | buildConfigurationList = DC70E7DE2264E0D000BBC128 /* Build configuration list for PBXProject "CXProvincesMapView" */; 162 | compatibilityVersion = "Xcode 9.3"; 163 | developmentRegion = en; 164 | hasScannedForEncodings = 0; 165 | knownRegions = ( 166 | en, 167 | Base, 168 | ); 169 | mainGroup = DC70E7DA2264E0D000BBC128; 170 | productRefGroup = DC70E7E42264E0D000BBC128 /* Products */; 171 | projectDirPath = ""; 172 | projectRoot = ""; 173 | targets = ( 174 | DC70E7E22264E0D000BBC128 /* CXProvincesMapView */, 175 | ); 176 | }; 177 | /* End PBXProject section */ 178 | 179 | /* Begin PBXResourcesBuildPhase section */ 180 | DC70E7E12264E0D000BBC128 /* Resources */ = { 181 | isa = PBXResourcesBuildPhase; 182 | buildActionMask = 2147483647; 183 | files = ( 184 | DC70E7F32264E0D100BBC128 /* LaunchScreen.storyboard in Resources */, 185 | DC70E7F02264E0D100BBC128 /* Assets.xcassets in Resources */, 186 | DC70E7EE2264E0D000BBC128 /* Main.storyboard in Resources */, 187 | ); 188 | runOnlyForDeploymentPostprocessing = 0; 189 | }; 190 | /* End PBXResourcesBuildPhase section */ 191 | 192 | /* Begin PBXSourcesBuildPhase section */ 193 | DC70E7DF2264E0D000BBC128 /* Sources */ = { 194 | isa = PBXSourcesBuildPhase; 195 | buildActionMask = 2147483647; 196 | files = ( 197 | DC70E7EB2264E0D000BBC128 /* ViewController.m in Sources */, 198 | DCAE735B227756AF002C1B7F /* StyleKitName.m in Sources */, 199 | CAE5647C23538FBE003CBD3F /* ChinaMapView.m in Sources */, 200 | CA69486D235EFF5F0088197C /* FujianMapController.m in Sources */, 201 | CA69486A235EFCE10088197C /* Fujian.m in Sources */, 202 | DC70E7F62264E0D100BBC128 /* main.m in Sources */, 203 | CA694867235EC48A0088197C /* FujianMapPath.m in Sources */, 204 | DC70E7E82264E0D000BBC128 /* AppDelegate.m in Sources */, 205 | CAE5647623538540003CBD3F /* CXProvincesMapView.m in Sources */, 206 | DCE8380F226E15310067AC93 /* SampleMapController.m in Sources */, 207 | DC5D89D6226B725700F16B77 /* SwiftLaunchView.m in Sources */, 208 | CAE5647B23538FBE003CBD3F /* ChinaMapPath.m in Sources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXSourcesBuildPhase section */ 213 | 214 | /* Begin PBXVariantGroup section */ 215 | DC70E7EC2264E0D000BBC128 /* Main.storyboard */ = { 216 | isa = PBXVariantGroup; 217 | children = ( 218 | DC70E7ED2264E0D000BBC128 /* Base */, 219 | ); 220 | name = Main.storyboard; 221 | sourceTree = ""; 222 | }; 223 | DC70E7F12264E0D100BBC128 /* LaunchScreen.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | DC70E7F22264E0D100BBC128 /* Base */, 227 | ); 228 | name = LaunchScreen.storyboard; 229 | sourceTree = ""; 230 | }; 231 | /* End PBXVariantGroup section */ 232 | 233 | /* Begin XCBuildConfiguration section */ 234 | DC70E7F72264E0D100BBC128 /* Debug */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_ANALYZER_NONNULL = YES; 239 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 240 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 241 | CLANG_CXX_LIBRARY = "libc++"; 242 | CLANG_ENABLE_MODULES = YES; 243 | CLANG_ENABLE_OBJC_ARC = YES; 244 | CLANG_ENABLE_OBJC_WEAK = YES; 245 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 246 | CLANG_WARN_BOOL_CONVERSION = YES; 247 | CLANG_WARN_COMMA = YES; 248 | CLANG_WARN_CONSTANT_CONVERSION = YES; 249 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 250 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 251 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 252 | CLANG_WARN_EMPTY_BODY = YES; 253 | CLANG_WARN_ENUM_CONVERSION = YES; 254 | CLANG_WARN_INFINITE_RECURSION = YES; 255 | CLANG_WARN_INT_CONVERSION = YES; 256 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 257 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 258 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 259 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 260 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 261 | CLANG_WARN_STRICT_PROTOTYPES = YES; 262 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 263 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 264 | CLANG_WARN_UNREACHABLE_CODE = YES; 265 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 266 | CODE_SIGN_IDENTITY = "iPhone Developer"; 267 | COPY_PHASE_STRIP = NO; 268 | DEBUG_INFORMATION_FORMAT = dwarf; 269 | ENABLE_STRICT_OBJC_MSGSEND = YES; 270 | ENABLE_TESTABILITY = YES; 271 | GCC_C_LANGUAGE_STANDARD = gnu11; 272 | GCC_DYNAMIC_NO_PIC = NO; 273 | GCC_NO_COMMON_BLOCKS = YES; 274 | GCC_OPTIMIZATION_LEVEL = 0; 275 | GCC_PREPROCESSOR_DEFINITIONS = ( 276 | "DEBUG=1", 277 | "$(inherited)", 278 | ); 279 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 280 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 281 | GCC_WARN_UNDECLARED_SELECTOR = YES; 282 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 283 | GCC_WARN_UNUSED_FUNCTION = YES; 284 | GCC_WARN_UNUSED_VARIABLE = YES; 285 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 286 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 287 | MTL_FAST_MATH = YES; 288 | ONLY_ACTIVE_ARCH = YES; 289 | SDKROOT = iphoneos; 290 | }; 291 | name = Debug; 292 | }; 293 | DC70E7F82264E0D100BBC128 /* Release */ = { 294 | isa = XCBuildConfiguration; 295 | buildSettings = { 296 | ALWAYS_SEARCH_USER_PATHS = NO; 297 | CLANG_ANALYZER_NONNULL = YES; 298 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 299 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 300 | CLANG_CXX_LIBRARY = "libc++"; 301 | CLANG_ENABLE_MODULES = YES; 302 | CLANG_ENABLE_OBJC_ARC = YES; 303 | CLANG_ENABLE_OBJC_WEAK = YES; 304 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 305 | CLANG_WARN_BOOL_CONVERSION = YES; 306 | CLANG_WARN_COMMA = YES; 307 | CLANG_WARN_CONSTANT_CONVERSION = YES; 308 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 309 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 310 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 311 | CLANG_WARN_EMPTY_BODY = YES; 312 | CLANG_WARN_ENUM_CONVERSION = YES; 313 | CLANG_WARN_INFINITE_RECURSION = YES; 314 | CLANG_WARN_INT_CONVERSION = YES; 315 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 316 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 317 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 318 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 319 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 320 | CLANG_WARN_STRICT_PROTOTYPES = YES; 321 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 322 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 323 | CLANG_WARN_UNREACHABLE_CODE = YES; 324 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 325 | CODE_SIGN_IDENTITY = "iPhone Developer"; 326 | COPY_PHASE_STRIP = NO; 327 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 328 | ENABLE_NS_ASSERTIONS = NO; 329 | ENABLE_STRICT_OBJC_MSGSEND = YES; 330 | GCC_C_LANGUAGE_STANDARD = gnu11; 331 | GCC_NO_COMMON_BLOCKS = YES; 332 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 333 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 334 | GCC_WARN_UNDECLARED_SELECTOR = YES; 335 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 336 | GCC_WARN_UNUSED_FUNCTION = YES; 337 | GCC_WARN_UNUSED_VARIABLE = YES; 338 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 339 | MTL_ENABLE_DEBUG_INFO = NO; 340 | MTL_FAST_MATH = YES; 341 | SDKROOT = iphoneos; 342 | VALIDATE_PRODUCT = YES; 343 | }; 344 | name = Release; 345 | }; 346 | DC70E7FA2264E0D100BBC128 /* Debug */ = { 347 | isa = XCBuildConfiguration; 348 | buildSettings = { 349 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 350 | CODE_SIGN_STYLE = Automatic; 351 | DEVELOPMENT_TEAM = 29C2LLD5FB; 352 | INFOPLIST_FILE = CXProvincesMapView/Info.plist; 353 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 354 | LD_RUNPATH_SEARCH_PATHS = ( 355 | "$(inherited)", 356 | "@executable_path/Frameworks", 357 | ); 358 | PRODUCT_BUNDLE_IDENTIFIER = com.CXTretar.CXProvincesMapView; 359 | PRODUCT_NAME = "$(TARGET_NAME)"; 360 | TARGETED_DEVICE_FAMILY = 1; 361 | }; 362 | name = Debug; 363 | }; 364 | DC70E7FB2264E0D100BBC128 /* Release */ = { 365 | isa = XCBuildConfiguration; 366 | buildSettings = { 367 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 368 | CODE_SIGN_STYLE = Automatic; 369 | DEVELOPMENT_TEAM = 29C2LLD5FB; 370 | INFOPLIST_FILE = CXProvincesMapView/Info.plist; 371 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 372 | LD_RUNPATH_SEARCH_PATHS = ( 373 | "$(inherited)", 374 | "@executable_path/Frameworks", 375 | ); 376 | PRODUCT_BUNDLE_IDENTIFIER = com.CXTretar.CXProvincesMapView; 377 | PRODUCT_NAME = "$(TARGET_NAME)"; 378 | TARGETED_DEVICE_FAMILY = 1; 379 | }; 380 | name = Release; 381 | }; 382 | /* End XCBuildConfiguration section */ 383 | 384 | /* Begin XCConfigurationList section */ 385 | DC70E7DE2264E0D000BBC128 /* Build configuration list for PBXProject "CXProvincesMapView" */ = { 386 | isa = XCConfigurationList; 387 | buildConfigurations = ( 388 | DC70E7F72264E0D100BBC128 /* Debug */, 389 | DC70E7F82264E0D100BBC128 /* Release */, 390 | ); 391 | defaultConfigurationIsVisible = 0; 392 | defaultConfigurationName = Release; 393 | }; 394 | DC70E7F92264E0D100BBC128 /* Build configuration list for PBXNativeTarget "CXProvincesMapView" */ = { 395 | isa = XCConfigurationList; 396 | buildConfigurations = ( 397 | DC70E7FA2264E0D100BBC128 /* Debug */, 398 | DC70E7FB2264E0D100BBC128 /* Release */, 399 | ); 400 | defaultConfigurationIsVisible = 0; 401 | defaultConfigurationName = Release; 402 | }; 403 | /* End XCConfigurationList section */ 404 | }; 405 | rootObject = DC70E7DB2264E0D000BBC128 /* Project object */; 406 | } 407 | -------------------------------------------------------------------------------- /CXProvincesMapView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CXProvincesMapView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CXProvincesMapView.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildSystemType 6 | Original 7 | PreviewsEnabled 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /CXProvincesMapView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/4/15. 6 | // Copyright © 2019 CXTretar. 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 | -------------------------------------------------------------------------------- /CXProvincesMapView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/4/15. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /CXProvincesMapView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /CXProvincesMapView/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CXProvincesMapView/Assets.xcassets/pin.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "pin.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "pin@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "pin@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CXProvincesMapView/Assets.xcassets/pin.imageset/pin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CXTretar/CXProvincesMapView/5c3b284b460fdf60784a01af17c74b12ff975985/CXProvincesMapView/Assets.xcassets/pin.imageset/pin.png -------------------------------------------------------------------------------- /CXProvincesMapView/Assets.xcassets/pin.imageset/pin@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CXTretar/CXProvincesMapView/5c3b284b460fdf60784a01af17c74b12ff975985/CXProvincesMapView/Assets.xcassets/pin.imageset/pin@2x.png -------------------------------------------------------------------------------- /CXProvincesMapView/Assets.xcassets/pin.imageset/pin@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CXTretar/CXProvincesMapView/5c3b284b460fdf60784a01af17c74b12ff975985/CXProvincesMapView/Assets.xcassets/pin.imageset/pin@3x.png -------------------------------------------------------------------------------- /CXProvincesMapView/Assets.xcassets/push_pin.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "push_pin_14.406477732794px_1206217_easyicon.net.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "push_pin_14.406477732794px_1206217_easyicon.net@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "push_pin_14.406477732794px_1206217_easyicon.net@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CXProvincesMapView/Assets.xcassets/push_pin.imageset/push_pin_14.406477732794px_1206217_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CXTretar/CXProvincesMapView/5c3b284b460fdf60784a01af17c74b12ff975985/CXProvincesMapView/Assets.xcassets/push_pin.imageset/push_pin_14.406477732794px_1206217_easyicon.net.png -------------------------------------------------------------------------------- /CXProvincesMapView/Assets.xcassets/push_pin.imageset/push_pin_14.406477732794px_1206217_easyicon.net@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CXTretar/CXProvincesMapView/5c3b284b460fdf60784a01af17c74b12ff975985/CXProvincesMapView/Assets.xcassets/push_pin.imageset/push_pin_14.406477732794px_1206217_easyicon.net@2x.png -------------------------------------------------------------------------------- /CXProvincesMapView/Assets.xcassets/push_pin.imageset/push_pin_14.406477732794px_1206217_easyicon.net@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CXTretar/CXProvincesMapView/5c3b284b460fdf60784a01af17c74b12ff975985/CXProvincesMapView/Assets.xcassets/push_pin.imageset/push_pin_14.406477732794px_1206217_easyicon.net@3x.png -------------------------------------------------------------------------------- /CXProvincesMapView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /CXProvincesMapView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /CXProvincesMapView/CXProvincesMapView/CXProvincesMapView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CXProvincesMapView.h 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/4/22. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import "ChinaMapPath.h" 12 | 13 | @protocol CXProvincesMapViewDelegate 14 | 15 | - (void)selectProvinceAtIndex:(NSInteger)index andName:(NSString *)name; 16 | 17 | @end 18 | 19 | @interface CXProvincesMapView : UIView 20 | 21 | @property(nonatomic, assign) NSInteger selectedIndex; // 选中省份的index 22 | @property(nonatomic, strong) UIColor *fillColor; // 省份的背景颜色 23 | @property(nonatomic, strong) UIColor *fillSelectedColor; // 选中省份的背景颜色 24 | @property(nonatomic, strong) UIColor *strokeColor; // 省份边界的颜色 25 | @property(nonatomic, strong) UIColor *strokeSelectedColor; // 选中省份边界的颜色 26 | @property(nonatomic, strong) UIColor *textColor; // 省份字体的颜色 27 | @property(nonatomic, strong) UIColor *textSelectedColor; // 选中省份字体的颜色 28 | 29 | @property(nonatomic, assign) CGFloat minimumZoomScale; // default is 1.0 30 | @property(nonatomic, assign) CGFloat maximumZoomScale; // default is 2.0 31 | 32 | @property(nonatomic, strong) UIView *pinView; // 图钉自定义视图 33 | @property(nonatomic, strong) UIImage *pinImage; // 图钉图片 34 | @property(nonatomic, assign) BOOL pinAnimation; // default is YES 图钉是否动画 35 | 36 | @property(nonatomic, weak) id delegate; 37 | 38 | /// 自定义的地图快捷创建方法 39 | /// @param mapPath svg 绘图数据 40 | /// @param mapSize svg 绘图尺寸 41 | /// @param frame 视图控件的frame 42 | - (instancetype)initWithMapPath:(ChinaMapPath *)mapPath andMapSize:(CGSize)mapSize andFrame:(CGRect)frame; 43 | 44 | @end 45 | 46 | -------------------------------------------------------------------------------- /CXProvincesMapView/CXProvincesMapView/CXProvincesMapView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CXProvincesMapView.m 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/4/22. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import "CXProvincesMapView.h" 10 | #import "ChinaMapView.h" 11 | 12 | @interface CXProvincesMapView() 13 | 14 | @property(nonatomic, strong) UIScrollView *scrollview; 15 | @property(nonatomic, strong) ChinaMapView *chinaMapView; 16 | 17 | @end 18 | 19 | @implementation CXProvincesMapView 20 | 21 | - (void)setPinAnimation:(BOOL)pinAnimation { 22 | _pinAnimation = pinAnimation; 23 | self.chinaMapView.pinAnimation = pinAnimation; 24 | } 25 | 26 | - (void)setPinImage:(UIImage *)pinImage { 27 | _pinImage = pinImage; 28 | self.chinaMapView.pinImage.image = pinImage; 29 | } 30 | 31 | - (void)setBackgroundColor:(UIColor *)backgroundColor { 32 | [super setBackgroundColor:backgroundColor]; 33 | _chinaMapView.backgroundColor = backgroundColor; 34 | } 35 | 36 | - (void)setSelectedIndex:(NSInteger)selectedIndex { 37 | _selectedIndex = selectedIndex; 38 | _chinaMapView.selectedIndex = selectedIndex; 39 | [self selectProvinceAtIndex:selectedIndex andName:self.chinaMapView.mapPath.textArray[selectedIndex]]; 40 | } 41 | 42 | - (void)setFillColor:(UIColor *)fillColor { 43 | _fillColor = fillColor; 44 | _chinaMapView.fillColor = fillColor; 45 | [_chinaMapView setNeedsDisplay]; 46 | } 47 | 48 | - (void)setFillSelectedColor:(UIColor *)fillSelectedColor { 49 | _fillSelectedColor = fillSelectedColor; 50 | _chinaMapView.fillSelectedColor = fillSelectedColor; 51 | [_chinaMapView setNeedsDisplay]; 52 | } 53 | 54 | - (void)setStrokeColor:(UIColor *)strokeColor { 55 | _strokeColor = strokeColor; 56 | _chinaMapView.strokeColor = strokeColor; 57 | [_chinaMapView setNeedsDisplay]; 58 | } 59 | 60 | - (void)setStrokeSelectedColor:(UIColor *)strokeSelectedColor { 61 | _strokeColor = strokeSelectedColor; 62 | _chinaMapView.strokeSelectedColor = strokeSelectedColor; 63 | [_chinaMapView setNeedsDisplay]; 64 | } 65 | 66 | - (void)setTextColor:(UIColor *)textColor { 67 | _textColor = textColor; 68 | _chinaMapView.textColor = textColor; 69 | [_chinaMapView setNeedsDisplay]; 70 | } 71 | 72 | - (void)setTextSelectedColor:(UIColor *)textSelectedColor { 73 | _textSelectedColor = textSelectedColor; 74 | _chinaMapView.textSelectedColor = textSelectedColor; 75 | [_chinaMapView setNeedsDisplay]; 76 | } 77 | 78 | - (void)setMaximumZoomScale:(CGFloat)maximumZoomScale { 79 | _maximumZoomScale = maximumZoomScale; 80 | self.scrollview.maximumZoomScale = maximumZoomScale; 81 | } 82 | 83 | - (void)setMinimumZoomScale:(CGFloat)minimumZoomScale { 84 | _minimumZoomScale = minimumZoomScale; 85 | self.scrollview.minimumZoomScale = minimumZoomScale; 86 | } 87 | 88 | 89 | - (instancetype)initWithMapPath:(ChinaMapPath *)mapPath andMapSize:(CGSize)mapSize andFrame:(CGRect)frame { 90 | if (self = [super initWithFrame:frame]) { 91 | // 检查 mapPath 格式 92 | if (mapPath.textArray.count < mapPath.textRectArray.count) { 93 | NSLog(@"textArray 与 textRectArray 数目不符"); 94 | NSMutableArray *tempArray = mapPath.textArray.mutableCopy; 95 | for (int i = 0; i < mapPath.textRectArray.count - mapPath.textArray.count; i++) { 96 | [tempArray addObject:@""]; 97 | } 98 | mapPath.textArray = tempArray.copy; 99 | } 100 | [self setupUI]; 101 | self.chinaMapView.mapWidth = 308; 102 | self.chinaMapView.mapHeight = 340; 103 | self.chinaMapView.mapPath = mapPath; 104 | self.chinaMapView.frame = self.scrollview.bounds; 105 | 106 | } 107 | return self; 108 | } 109 | 110 | - (instancetype)initWithFrame:(CGRect)frame { 111 | if (self = [super initWithFrame:frame]) { 112 | [self setupUI]; 113 | self.chinaMapView.frame = self.scrollview.bounds; 114 | } 115 | 116 | return self; 117 | } 118 | 119 | - (void)setupUI { 120 | 121 | self.scrollview = [[UIScrollView alloc] initWithFrame:self.bounds]; 122 | _scrollview.showsVerticalScrollIndicator = NO; 123 | _scrollview.showsHorizontalScrollIndicator = NO; 124 | //设置实现缩放 125 | //设置代理scrollview的代理对象 126 | _scrollview.delegate = self; 127 | //设置最大伸缩比例 128 | _scrollview.maximumZoomScale = 10.0; 129 | //设置最小伸缩比例 130 | _scrollview.minimumZoomScale = 1.0; 131 | [_scrollview setZoomScale:1.0 animated:NO]; 132 | [self addSubview: _scrollview]; 133 | 134 | self.chinaMapView = [[ChinaMapView alloc] init]; 135 | typeof(self) __weak weakSelf = self; 136 | self.chinaMapView.block = ^(NSInteger index, NSString *name) { 137 | weakSelf.selectedIndex = index; 138 | }; 139 | [_scrollview addSubview: _chinaMapView]; 140 | self.pinImage = self.chinaMapView.pinImage.image; 141 | self.pinView = self.chinaMapView.pinView; 142 | 143 | 144 | } 145 | 146 | - (void)setFrame:(CGRect)frame { 147 | self.scrollview.frame = self.bounds; 148 | self.chinaMapView.frame = self.scrollview.bounds; 149 | [_scrollview setZoomScale:1.0 animated:NO]; 150 | [super setFrame:frame]; 151 | } 152 | 153 | // 告诉scrollview要缩放的是哪个子控件 154 | - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { 155 | return _chinaMapView; 156 | } 157 | 158 | // 这个方法是针对scrollView在缩小时无法居中的问题,scrollView放大,只要在设置完zoomScale之后设置偏移量为(0,0)即可实现放大居中 159 | - (void)scrollViewDidZoom:(UIScrollView *)scrollView { 160 | 161 | CGFloat offsetX = MAX((scrollView.bounds.size.width - scrollView.contentInset.left - scrollView.contentInset.right - scrollView.contentSize.width) * 0.5, 0.0); 162 | CGFloat offsetY = MAX((scrollView.bounds.size.height - scrollView.contentInset.top - scrollView.contentInset.bottom - scrollView.contentSize.height) * 0.5, 0.0); 163 | 164 | self.chinaMapView.center = CGPointMake(scrollView.contentSize.width * 0.5 + offsetX, 165 | scrollView.contentSize.height * 0.5 + offsetY); 166 | 167 | } 168 | 169 | #pragma mark - CXProvincesMapViewDelegate 170 | 171 | - (void)selectProvinceAtIndex:(NSInteger)index andName:(NSString *)name { 172 | if ([self.delegate respondsToSelector:@selector(selectProvinceAtIndex:andName:)]) { 173 | [self.delegate selectProvinceAtIndex:index andName:name]; 174 | } 175 | } 176 | 177 | 178 | @end 179 | -------------------------------------------------------------------------------- /CXProvincesMapView/CXProvincesMapView/ChinaMapPath.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChinaMapPath.h 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/4/29. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ChinaMapPath : NSObject { 12 | NSArray *_pathArray; 13 | NSArray *_textArray; 14 | NSArray *_textRectArray; 15 | NSArray *_pinPointArray; 16 | } 17 | 18 | @property(nonatomic, copy) NSArray *pathArray; 19 | @property(nonatomic, copy) NSArray *textArray; 20 | @property(nonatomic, copy) NSArray *textRectArray; 21 | @property(nonatomic, copy) NSArray *pinPointArray; 22 | 23 | @end 24 | 25 | -------------------------------------------------------------------------------- /CXProvincesMapView/CXProvincesMapView/ChinaMapView.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChinaMapView.h 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/5/19. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ChinaMapPath.h" 11 | 12 | typedef void (^ChinaMapViewSelectBlock)(NSInteger index, NSString *name); 13 | 14 | @interface ChinaMapView : UIView 15 | 16 | @property(nonatomic, strong) ChinaMapPath *mapPath; 17 | @property(nonatomic, copy) ChinaMapViewSelectBlock block; 18 | @property(nonatomic, assign) NSInteger selectedIndex; 19 | @property(nonatomic, strong) UIColor *fillColor; 20 | @property(nonatomic, strong) UIColor *fillSelectedColor; 21 | @property(nonatomic, strong) UIColor *strokeColor; 22 | @property(nonatomic, strong) UIColor *strokeSelectedColor; 23 | @property(nonatomic, strong) UIColor *textColor; 24 | @property(nonatomic, strong) UIColor *textSelectedColor; 25 | 26 | @property(nonatomic, assign) CGFloat mapWidth; 27 | @property(nonatomic, assign) CGFloat mapHeight; 28 | 29 | @property(nonatomic, strong) UIView *pinView; 30 | @property(nonatomic, strong) UIImageView *pinImage; 31 | @property(nonatomic, assign) BOOL pinAnimation; 32 | 33 | @end 34 | 35 | -------------------------------------------------------------------------------- /CXProvincesMapView/CXProvincesMapView/ChinaMapView.m: -------------------------------------------------------------------------------- 1 | // 2 | // ChinaMapView.m 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/5/19. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import "ChinaMapView.h" 10 | 11 | #define MAP_SIZE_WIDTH 774 12 | #define MAP_SIZE_HEIGHT 569 13 | #define DEFAULT_FILL_COLOR [UIColor colorWithRed: 0.8 green: 0.8 blue: 0.8 alpha: 1] 14 | #define DEFAULT_FILL_SELECTED_COLOR [UIColor colorWithRed: 0.4 green: 0.3 blue: 0.8 alpha: 1] 15 | #define DEFAULT_STROKE_COLOR [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 1] 16 | #define DEFAULT_STROKE_SELECTED_COLOR [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 1] 17 | #define DEFAULT_TEXT_COLOR [UIColor blackColor] 18 | #define DEFAULT_TEXT_SELECTED_COLOR [UIColor redColor] 19 | 20 | @interface ChinaMapView () 21 | 22 | @property(nonatomic, strong) NSMutableArray *pathColorArray; 23 | @property(nonatomic, strong) NSMutableArray *strokeColorArray; 24 | @property(nonatomic, strong) NSMutableArray *textColorArray; 25 | 26 | @end 27 | 28 | @implementation ChinaMapView 29 | 30 | - (void)setMapPath:(ChinaMapPath *)mapPath { 31 | _mapPath = mapPath; 32 | [self setNeedsDisplay]; 33 | } 34 | 35 | - (void)setSelectedIndex:(NSInteger)selectedIndex { 36 | _selectedIndex = selectedIndex; 37 | [self setNeedsDisplay]; 38 | [self showPinViewWithAnimation:_pinAnimation]; 39 | } 40 | 41 | - (void)setFillColor:(UIColor *)fillColor { 42 | _pathColorArray = [NSMutableArray arrayWithCapacity: self.mapPath.pathArray.count]; 43 | for (int i = 0; i < _mapPath.pathArray.count; i++) { 44 | [_pathColorArray addObject:fillColor]; 45 | } 46 | _fillColor = fillColor; 47 | } 48 | 49 | - (void)setFillSelectedColor:(UIColor *)fillSelectedColor { 50 | _fillSelectedColor = fillSelectedColor; 51 | if (_selectedIndex >= 0) { 52 | _pathColorArray[_selectedIndex] = _fillSelectedColor; 53 | } 54 | } 55 | 56 | - (void)setStrokeColor:(UIColor *)strokeColor { 57 | _strokeColorArray = [NSMutableArray arrayWithCapacity: self.mapPath.pathArray.count]; 58 | for (int i = 0; i < _mapPath.pathArray.count; i++) { 59 | [_strokeColorArray addObject:strokeColor]; 60 | } 61 | _strokeColor = strokeColor; 62 | } 63 | 64 | - (void)setStrokeSelectedColor:(UIColor *)strokeSelectedColor { 65 | _strokeSelectedColor = strokeSelectedColor; 66 | if (_selectedIndex >= 0) { 67 | _strokeColorArray[_selectedIndex] = _strokeSelectedColor; 68 | } 69 | } 70 | 71 | - (void)setTextColor:(UIColor *)textColor { 72 | _textColorArray = [NSMutableArray arrayWithCapacity: self.mapPath.pathArray.count]; 73 | for (int i = 0; i < _mapPath.pathArray.count; i++) { 74 | [_textColorArray addObject:textColor]; 75 | } 76 | _textColor = textColor; 77 | } 78 | 79 | - (void)setTextSelectedColor:(UIColor *)textSelectedColor { 80 | _textSelectedColor = textSelectedColor; 81 | if (_selectedIndex >= 0) { 82 | _textColorArray[_selectedIndex] = _textSelectedColor; 83 | } 84 | } 85 | 86 | - (instancetype)init { 87 | if (self = [super init]) { 88 | self.mapPath = [[ChinaMapPath alloc] init]; 89 | self.mapWidth = MAP_SIZE_WIDTH; 90 | self.mapHeight = MAP_SIZE_HEIGHT; 91 | self.selectedIndex = -1; 92 | self.fillColor = DEFAULT_FILL_COLOR; 93 | self.fillSelectedColor = DEFAULT_FILL_SELECTED_COLOR; 94 | self.strokeColor = DEFAULT_STROKE_COLOR; 95 | self.strokeSelectedColor = DEFAULT_STROKE_SELECTED_COLOR; 96 | self.textColor = DEFAULT_TEXT_COLOR; 97 | self.textSelectedColor = DEFAULT_TEXT_SELECTED_COLOR; 98 | self.pinAnimation = YES; 99 | self.pinView = [UIView new]; 100 | self.pinImage = [UIImageView new]; 101 | [self.pinView addSubview:self.pinImage]; 102 | UITapGestureRecognizer *click = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click:)]; 103 | [self addGestureRecognizer:click]; 104 | } 105 | 106 | return self; 107 | } 108 | 109 | - (void)setFrame:(CGRect)frame { 110 | [super setFrame:frame]; 111 | [self setNeedsDisplay]; 112 | [self showPinViewWithAnimation:NO]; 113 | if (_selectedIndex < 0) { 114 | CGRect resizedFrame = [self resizing:CGRectMake(0, 0, _mapWidth, _mapHeight) target:frame]; 115 | CGFloat width = 20 * resizedFrame.size.width / _mapWidth; 116 | CGFloat height = 20 * resizedFrame.size.height / _mapHeight; 117 | self.pinView.frame = CGRectMake(0, 0, width, height); 118 | } 119 | 120 | } 121 | 122 | - (void)showPinViewWithAnimation:(BOOL)isAnimation { 123 | if (_selectedIndex < 0) return; 124 | 125 | CGPoint pinPoint = CGPointFromString(self.mapPath.pinPointArray[_selectedIndex]); 126 | CGRect resizedFrame = [self resizing:CGRectMake(0, 0, _mapWidth, _mapHeight) target:self.bounds]; 127 | CGFloat x = resizedFrame.origin.x + pinPoint.x * resizedFrame.size.width / _mapWidth; 128 | CGFloat y = resizedFrame.origin.y + pinPoint.y * resizedFrame.size.height / _mapHeight; 129 | CGFloat width = 20 * resizedFrame.size.width / _mapWidth; 130 | CGFloat height = 20 * resizedFrame.size.height / _mapHeight; 131 | 132 | self.pinView.frame = CGRectMake(x, y, width, height); 133 | self.pinImage.frame = self.pinView.bounds; 134 | [self addSubview:self.pinView]; 135 | 136 | if (isAnimation) { 137 | CGPoint center = self.pinView.center; 138 | CGFloat change = 10 * resizedFrame.size.height / _mapHeight; 139 | self.pinView.center = CGPointMake(center.x, center.y - change); 140 | [UIView animateWithDuration:0.2 animations:^{ 141 | self.pinView.center = CGPointMake(center.x, center.y); 142 | }]; 143 | } 144 | } 145 | 146 | 147 | - (void)click:(UITapGestureRecognizer *)sender { 148 | 149 | CGPoint point = [sender locationInView:sender.view]; 150 | 151 | CGRect resizedFrame = [self resizing:CGRectMake(0, 0, _mapWidth, _mapHeight) target:self.bounds]; 152 | point = CGPointMake((point.x - resizedFrame.origin.x) * _mapWidth / resizedFrame.size.width, (point.y - resizedFrame.origin.y) * _mapHeight /resizedFrame.size.height); 153 | 154 | for (int i = 0; i < self.mapPath.pathArray.count; i++) { 155 | UIBezierPath *path = self.mapPath.pathArray[i]; 156 | 157 | if ([path containsPoint:point]) { 158 | 159 | //清除之前选中的颜色,fill当前选中的颜色 160 | if (_selectedIndex >= 0) { 161 | self.pathColorArray[_selectedIndex] = self.fillColor; 162 | self.strokeColorArray[_selectedIndex] = self.strokeColor; 163 | self.textColorArray[_selectedIndex] = self.textColor; 164 | } 165 | 166 | self.selectedIndex = i; 167 | self.pathColorArray[i] = self.fillSelectedColor; 168 | self.strokeColorArray[i] = self.strokeSelectedColor; 169 | self.textColorArray[i] = self.textSelectedColor; 170 | if (_selectedIndex != i) { 171 | [self setNeedsDisplay]; 172 | } 173 | [self showPinViewWithAnimation:_pinAnimation]; 174 | if (self.block) { 175 | self.block(i, self.mapPath.textArray[i]); 176 | } 177 | break; 178 | } 179 | } 180 | 181 | } 182 | 183 | - (void)drawRect:(CGRect)rect { 184 | //// General Declarations 185 | CGContextRef context = UIGraphicsGetCurrentContext(); 186 | 187 | //// Resize to Target Frame 188 | CGContextSaveGState(context); 189 | CGRect resizedFrame = [self resizing:CGRectMake(0, 0, _mapWidth, _mapHeight) target: self.bounds]; 190 | CGContextTranslateCTM(context, resizedFrame.origin.x, resizedFrame.origin.y); 191 | CGContextScaleCTM(context, resizedFrame.size.width / _mapWidth, resizedFrame.size.height / _mapHeight); 192 | 193 | [self.mapPath.pathArray enumerateObjectsUsingBlock:^(UIBezierPath *path, NSUInteger idx, BOOL * _Nonnull stop) { 194 | [self.pathColorArray[idx] setFill]; 195 | [path fill]; 196 | [self.strokeColorArray[idx] setStroke]; 197 | path.lineWidth = 0.5; 198 | path.miterLimit = 4; 199 | 200 | [path stroke]; 201 | 202 | }]; 203 | 204 | 205 | for (int i = 0; i < self.mapPath.textRectArray.count; i++) { 206 | CGRect textRect = [self.mapPath.textRectArray[i] CGRectValue]; 207 | NSString *textContent = self.mapPath.textArray[i]; 208 | NSMutableParagraphStyle* textStyle = [[NSMutableParagraphStyle alloc] init]; 209 | textStyle.alignment = NSTextAlignmentLeft; 210 | NSDictionary* textFontAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize: 11], NSForegroundColorAttributeName: self.textColorArray[i], NSParagraphStyleAttributeName: textStyle}; 211 | 212 | CGFloat textTextHeight = [textContent boundingRectWithSize: CGSizeMake(textRect.size.width, INFINITY) options: NSStringDrawingUsesLineFragmentOrigin attributes: textFontAttributes context: nil].size.height; 213 | CGContextSaveGState(context); 214 | CGContextClipToRect(context, textRect); 215 | [textContent drawInRect: CGRectMake(CGRectGetMinX(textRect), CGRectGetMinY(textRect) + (textRect.size.height - textTextHeight) / 2, textRect.size.width, textTextHeight) withAttributes: textFontAttributes]; 216 | CGContextRestoreGState(context); 217 | } 218 | } 219 | 220 | - (CGRect)resizing:(CGRect)rect target:(CGRect)target { 221 | if (CGRectEqualToRect(rect, target) || CGRectEqualToRect(target, CGRectZero)) 222 | return rect; 223 | 224 | CGSize scales = CGSizeZero; 225 | scales.width = ABS(target.size.width / rect.size.width); 226 | scales.height = ABS(target.size.height / rect.size.height); 227 | 228 | scales.width = MIN(scales.width, scales.height); 229 | scales.height = scales.width; 230 | 231 | CGRect result = CGRectStandardize(rect); 232 | result.size.width *= scales.width; 233 | result.size.height *= scales.height; 234 | result.origin.x = target.origin.x + (target.size.width - result.size.width) / 2; 235 | result.origin.y = target.origin.y + (target.size.height - result.size.height) / 2; 236 | return result; 237 | } 238 | 239 | 240 | 241 | @end 242 | -------------------------------------------------------------------------------- /CXProvincesMapView/Fujian.h: -------------------------------------------------------------------------------- 1 | // 2 | // Fujian.h 3 | // ProjectName 4 | // 5 | // Created by AuthorName on 2019/10/22. 6 | // Copyright © 2019 CompanyName. All rights reserved. 7 | // 8 | // Generated by PaintCode 9 | // http://www.paintcodeapp.com 10 | // 11 | 12 | #import 13 | 14 | 15 | 16 | typedef NS_ENUM(NSInteger, FujianResizingBehavior) 17 | { 18 | FujianResizingBehaviorAspectFit, //!< The content is proportionally resized to fit into the target rectangle. 19 | FujianResizingBehaviorAspectFill, //!< The content is proportionally resized to completely fill the target rectangle. 20 | FujianResizingBehaviorStretch, //!< The content is stretched to match the entire target rectangle. 21 | FujianResizingBehaviorCenter, //!< The content is centered in the target rectangle, but it is NOT resized. 22 | 23 | }; 24 | 25 | extern CGRect FujianResizingBehaviorApply(FujianResizingBehavior behavior, CGRect rect, CGRect target); 26 | 27 | 28 | @interface Fujian : NSObject 29 | 30 | // Drawing Methods 31 | + (void)drawCanvas2; 32 | + (void)drawCanvas2WithFrame: (CGRect)targetFrame resizing: (FujianResizingBehavior)resizing; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /CXProvincesMapView/FujianMapController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FujianMapController.h 3 | // CXProvincesMapView 4 | // 5 | // Created by CXTretar on 2019/10/22. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FujianMapController : UIViewController 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /CXProvincesMapView/FujianMapController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FujianMapController.m 3 | // CXProvincesMapView 4 | // 5 | // Created by CXTretar on 2019/10/22. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import "FujianMapController.h" 10 | #import "CXProvincesMapView.h" 11 | #import "FujianMapPath.h" 12 | 13 | @interface FujianMapController () 14 | 15 | @property (nonatomic, strong) CXProvincesMapView *chinaMapView; 16 | 17 | @end 18 | 19 | @implementation FujianMapController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | self.view.backgroundColor = [UIColor whiteColor]; 24 | // 福建省市数据 25 | FujianMapPath *mapPath = [[FujianMapPath alloc] init]; 26 | self.chinaMapView = [[CXProvincesMapView alloc]initWithMapPath:mapPath andMapSize:CGSizeMake(308, 340) andFrame:CGRectMake(0, 0, self.view.bounds.size.width, 400)]; 27 | _chinaMapView.backgroundColor = [UIColor colorWithRed:230/255.0 green:1.0 blue:1.0 alpha:1.0]; 28 | _chinaMapView.maximumZoomScale = 5.0; 29 | _chinaMapView.center = self.view.center; 30 | _chinaMapView.delegate = self; 31 | // _chinaMapView.pinAnimation = NO; 32 | // 直接设置图片 33 | // _chinaMapView.pinImage = [UIImage imageNamed:@"pin"]; 34 | // 添加按钮点击 35 | UIButton *pinButton = [[UIButton alloc]initWithFrame:_chinaMapView.pinView.bounds]; 36 | [pinButton setImage:[UIImage imageNamed:@"pin"] forState:UIControlStateNormal]; 37 | [pinButton addTarget:self action:@selector(pinTest) forControlEvents:UIControlEventTouchUpInside]; 38 | [_chinaMapView.pinView addSubview:pinButton]; 39 | [self.view addSubview:_chinaMapView]; 40 | } 41 | 42 | - (void)viewDidLayoutSubviews { 43 | [super viewDidLayoutSubviews]; 44 | // 45 | if (self.view.bounds.size.width > self.view.bounds.size.height) { 46 | self.chinaMapView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 400); 47 | } else { 48 | self.chinaMapView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 400); 49 | } 50 | self.chinaMapView.center = self.view.center; 51 | } 52 | 53 | - (void)selectProvinceAtIndex:(NSInteger)index andName:(NSString *)name { 54 | NSLog(@"福建省 - %ld - %@", (long)index, name); 55 | self.title = [NSString stringWithFormat:@"福建省 - %ld - %@", (long)index, name]; 56 | } 57 | 58 | - (void)pinTest { 59 | NSLog(@"%s", __func__); 60 | } 61 | 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /CXProvincesMapView/FujianMapPath.h: -------------------------------------------------------------------------------- 1 | // 2 | // FujianMapPath.h 3 | // CXProvincesMapView 4 | // 5 | // Created by CXTretar on 2019/10/22. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import "ChinaMapPath.h" 10 | 11 | @interface FujianMapPath : ChinaMapPath 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /CXProvincesMapView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /CXProvincesMapView/SampleMapController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SampleMapController.h 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/4/22. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface SampleMapController : UIViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /CXProvincesMapView/SampleMapController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SampleMapController.m 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/4/22. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import "SampleMapController.h" 10 | #import "CXProvincesMapView.h" 11 | #import "FujianMapController.h" 12 | 13 | @interface SampleMapController () 14 | 15 | @property (nonatomic, strong) CXProvincesMapView *chinaMapView; 16 | 17 | @end 18 | 19 | @implementation SampleMapController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | self.title = @"SampleMapController"; 24 | self.view.backgroundColor = [UIColor whiteColor]; 25 | 26 | self.chinaMapView = [[CXProvincesMapView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 400)]; 27 | _chinaMapView.backgroundColor = [UIColor colorWithRed:230/255.0 green:1.0 blue:1.0 alpha:1.0]; 28 | _chinaMapView.maximumZoomScale = 5.0; 29 | _chinaMapView.delegate = self; 30 | _chinaMapView.center = self.view.center; 31 | // _chinaMapView.pinAnimation = NO; 32 | // 直接设置图片 33 | // _chinaMapView.pinImage = [UIImage imageNamed:@"pin"]; 34 | // 添加按钮点击 35 | UIButton *pinButton = [[UIButton alloc]initWithFrame:_chinaMapView.pinView.bounds]; 36 | [pinButton setImage:[UIImage imageNamed:@"pin"] forState:UIControlStateNormal]; 37 | [pinButton addTarget:self action:@selector(pinTest) forControlEvents:UIControlEventTouchUpInside]; 38 | [_chinaMapView.pinView addSubview:pinButton]; 39 | 40 | [self.view addSubview:_chinaMapView]; 41 | } 42 | 43 | - (void)viewDidLayoutSubviews { 44 | [super viewDidLayoutSubviews]; 45 | // 46 | if (self.view.bounds.size.width > self.view.bounds.size.height) { 47 | self.chinaMapView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 400); 48 | } else { 49 | self.chinaMapView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 400); 50 | } 51 | self.chinaMapView.center = self.view.center; 52 | } 53 | 54 | - (void)selectProvinceAtIndex:(NSInteger)index andName:(NSString *)name { 55 | NSLog(@"Province - %ld - %@", (long)index, name); 56 | self.title = [NSString stringWithFormat:@"Province - %ld - %@", (long)index, name]; 57 | if ([name isEqualToString:@"福建省"]) { 58 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 59 | FujianMapController *mapVC = [[FujianMapController alloc] init]; 60 | mapVC.title = name; 61 | [self.navigationController pushViewController:mapVC animated:YES]; 62 | }); 63 | } 64 | 65 | } 66 | 67 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 68 | _chinaMapView.selectedIndex = 0; 69 | _chinaMapView.fillColor = [UIColor cyanColor]; 70 | _chinaMapView.fillSelectedColor = [UIColor greenColor]; 71 | _chinaMapView.strokeColor = [UIColor whiteColor]; 72 | _chinaMapView.strokeSelectedColor = [UIColor greenColor]; 73 | _chinaMapView.textColor = [UIColor blueColor]; 74 | _chinaMapView.textSelectedColor = [UIColor orangeColor]; 75 | 76 | } 77 | 78 | - (void)pinTest { 79 | NSLog(@"%s", __func__); 80 | } 81 | 82 | - (void)dealloc { 83 | NSLog(@"%s", __func__); 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /CXProvincesMapView/StyleKitName.h: -------------------------------------------------------------------------------- 1 | // 2 | // StyleKitName.h 3 | // ProjectName 4 | // 5 | // Created by AuthorName on 2019/4/29. 6 | // Copyright © 2019 CompanyName. All rights reserved. 7 | // 8 | // Generated by PaintCode 9 | // http://www.paintcodeapp.com 10 | // 11 | 12 | #import 13 | 14 | 15 | 16 | typedef NS_ENUM(NSInteger, StyleKitNameResizingBehavior) 17 | { 18 | StyleKitNameResizingBehaviorAspectFit, //!< The content is proportionally resized to fit into the target rectangle. 19 | StyleKitNameResizingBehaviorAspectFill, //!< The content is proportionally resized to completely fill the target rectangle. 20 | StyleKitNameResizingBehaviorStretch, //!< The content is stretched to match the entire target rectangle. 21 | StyleKitNameResizingBehaviorCenter, //!< The content is centered in the target rectangle, but it is NOT resized. 22 | 23 | }; 24 | 25 | extern CGRect StyleKitNameResizingBehaviorApply(StyleKitNameResizingBehavior behavior, CGRect rect, CGRect target); 26 | 27 | 28 | @interface StyleKitName : NSObject 29 | 30 | // Drawing Methods 31 | + (void)drawCanvas2; 32 | + (void)drawCanvas2WithFrame: (CGRect)targetFrame resizing: (StyleKitNameResizingBehavior)resizing; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /CXProvincesMapView/SwiftLaunchView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftLaunchView.h 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/4/20. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface SwiftLaunchView : UIView 14 | 15 | + (void)launchAnimation; 16 | 17 | @end 18 | 19 | NS_ASSUME_NONNULL_END 20 | -------------------------------------------------------------------------------- /CXProvincesMapView/SwiftLaunchView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftLaunchView.m 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/4/20. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import "SwiftLaunchView.h" 10 | 11 | @interface SwiftLaunchView() 12 | 13 | @property(nonatomic, strong) UIView *launchView; 14 | 15 | @end 16 | 17 | @implementation SwiftLaunchView 18 | 19 | + (void)launchAnimation { 20 | //获取到LaunchScreen控制器(不要忘记id) 21 | UIViewController *launchScreenController = [[UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil] instantiateViewControllerWithIdentifier:@"LaunchScreen"]; 22 | 23 | //获取LaunchScreen的view 24 | UIView *launchView = launchScreenController.view; 25 | UIWindow *mainWindow = [UIApplication sharedApplication].keyWindow; 26 | launchView.frame = [UIApplication sharedApplication].keyWindow.frame; 27 | [mainWindow addSubview:launchView]; 28 | 29 | //添加launchView类 30 | SwiftLaunchView *swiftLaunchView = [[SwiftLaunchView alloc]initWithFrame:[UIScreen mainScreen].bounds]; 31 | [launchView addSubview:swiftLaunchView]; 32 | //最后移除 33 | [UIView animateWithDuration:0.5f delay:2.5f options:UIViewAnimationOptionBeginFromCurrentState animations:^{ 34 | launchView.alpha = 0.0f; 35 | } completion:^(BOOL finished) { 36 | [launchView removeFromSuperview]; 37 | }]; 38 | 39 | } 40 | 41 | - (instancetype)initWithFrame:(CGRect)frame { 42 | if (self = [super initWithFrame:frame]) { 43 | [self addLayerToLaunchView]; 44 | } 45 | return self; 46 | } 47 | 48 | - (void)addLayerToLaunchView { 49 | //添加launchView 50 | self.launchView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 150, 150)]; 51 | self.launchView.backgroundColor = [UIColor clearColor]; 52 | self.launchView.center = self.center; 53 | [self addSubview:self.launchView]; 54 | 55 | // 添加layer 56 | CAShapeLayer *layer = [[CAShapeLayer alloc]init]; 57 | layer.path = [self swiftBezierPath].CGPath; 58 | layer.bounds = CGPathGetBoundingBox(layer.path); 59 | self.backgroundColor = [UIColor colorWithRed:247/255.0 green:147/255.0 blue:55/255.0 alpha:1.0]; 60 | layer.position = CGPointMake(self.launchView.bounds.size.width / 2, self.launchView.bounds.size.height/ 2); 61 | layer.fillColor = [UIColor whiteColor].CGColor; 62 | [self.launchView.layer addSublayer:layer]; 63 | 64 | //执行动画 65 | [self performSelector:@selector(startLaunch) withObject:nil afterDelay:1.0]; 66 | } 67 | 68 | - (void)startLaunch { 69 | [UIView animateWithDuration:1 animations:^{ 70 | //先缩小launchView 71 | self.launchView.transform = CGAffineTransformMakeScale(0.5, 0.5); 72 | 73 | } completion:^(BOOL finished) { 74 | [UIView animateWithDuration:1 animations:^{ 75 | 76 | //在无线放大launchView 77 | self.launchView.transform = CGAffineTransformMakeScale(50, 50); 78 | self.launchView.alpha = 0; 79 | } completion:^(BOOL finished) { 80 | 81 | //最后移除 82 | [self.launchView removeFromSuperview]; 83 | [self removeFromSuperview]; 84 | }];; 85 | }]; 86 | } 87 | 88 | // PaintCode 绘制的swift 89 | - (UIBezierPath *)swiftBezierPath { 90 | UIColor* strokeColor = [UIColor colorWithRed: 0.592 green: 0.592 blue: 0.592 alpha: 1]; 91 | //// Path Drawing 92 | UIBezierPath* pathPath = [UIBezierPath bezierPath]; 93 | [pathPath moveToPoint: CGPointMake(33.24, 187.6)]; 94 | [pathPath addLineToPoint: CGPointMake(45.98, 199.12)]; 95 | [pathPath addLineToPoint: CGPointMake(61.06, 212.05)]; 96 | [pathPath addLineToPoint: CGPointMake(84.51, 230.28)]; 97 | [pathPath addLineToPoint: CGPointMake(96.33, 239.24)]; 98 | [pathPath addLineToPoint: CGPointMake(105.6, 245.76)]; 99 | [pathPath addLineToPoint: CGPointMake(107.78, 238.82)]; 100 | [pathPath addLineToPoint: CGPointMake(108.9, 232.53)]; 101 | [pathPath addLineToPoint: CGPointMake(109.77, 225.01)]; 102 | [pathPath addLineToPoint: CGPointMake(109.44, 217.6)]; 103 | [pathPath addLineToPoint: CGPointMake(108.66, 210.98)]; 104 | [pathPath addLineToPoint: CGPointMake(107.06, 203.96)]; 105 | [pathPath addLineToPoint: CGPointMake(105.45, 199.44)]; 106 | [pathPath addLineToPoint: CGPointMake(103.86, 194.59)]; 107 | [pathPath addLineToPoint: CGPointMake(101.64, 189.87)]; 108 | [pathPath addLineToPoint: CGPointMake(98.56, 183.6)]; 109 | [pathPath addLineToPoint: CGPointMake(96.98, 180.88)]; 110 | [pathPath addLineToPoint: CGPointMake(94.58, 176.31)]; 111 | [pathPath addLineToPoint: CGPointMake(92.99, 174)]; 112 | [pathPath addLineToPoint: CGPointMake(101.56, 180.44)]; 113 | [pathPath addLineToPoint: CGPointMake(107.22, 185.31)]; 114 | [pathPath addLineToPoint: CGPointMake(118.36, 195.86)]; 115 | [pathPath addLineToPoint: CGPointMake(128.55, 209.57)]; 116 | [pathPath addLineToPoint: CGPointMake(134.08, 220.04)]; 117 | [pathPath addLineToPoint: CGPointMake(137.67, 230.03)]; 118 | [pathPath addLineToPoint: CGPointMake(139.31, 239.28)]; 119 | [pathPath addLineToPoint: CGPointMake(140.32, 248.41)]; 120 | [pathPath addLineToPoint: CGPointMake(139.74, 256.97)]; 121 | [pathPath addLineToPoint: CGPointMake(137.21, 267.21)]; 122 | [pathPath addLineToPoint: CGPointMake(138.15, 269.79)]; 123 | [pathPath addLineToPoint: CGPointMake(141.7, 274.47)]; 124 | [pathPath addLineToPoint: CGPointMake(145.3, 280.74)]; 125 | [pathPath addLineToPoint: CGPointMake(148.58, 288.67)]; 126 | [pathPath addLineToPoint: CGPointMake(150, 296.99)]; 127 | [pathPath addLineToPoint: CGPointMake(149.5, 303.95)]; 128 | [pathPath addLineToPoint: CGPointMake(148.39, 306.84)]; 129 | [pathPath addLineToPoint: CGPointMake(146.55, 305.89)]; 130 | [pathPath addLineToPoint: CGPointMake(143.02, 301.51)]; 131 | [pathPath addLineToPoint: CGPointMake(138.58, 298.13)]; 132 | [pathPath addLineToPoint: CGPointMake(134.64, 296.23)]; 133 | [pathPath addLineToPoint: CGPointMake(129.48, 294.8)]; 134 | [pathPath addLineToPoint: CGPointMake(124.78, 294.81)]; 135 | [pathPath addLineToPoint: CGPointMake(120.29, 295.69)]; 136 | [pathPath addLineToPoint: CGPointMake(115.38, 298.15)]; 137 | [pathPath addLineToPoint: CGPointMake(108.58, 301.74)]; 138 | [pathPath addLineToPoint: CGPointMake(97.17, 305.98)]; 139 | [pathPath addLineToPoint: CGPointMake(89.95, 307.29)]; 140 | [pathPath addLineToPoint: CGPointMake(80.86, 307.58)]; 141 | [pathPath addLineToPoint: CGPointMake(72.62, 306.93)]; 142 | [pathPath addLineToPoint: CGPointMake(59.21, 304.66)]; 143 | [pathPath addLineToPoint: CGPointMake(47.38, 301.09)]; 144 | [pathPath addLineToPoint: CGPointMake(37.51, 296.56)]; 145 | [pathPath addLineToPoint: CGPointMake(28.33, 290.85)]; 146 | [pathPath addLineToPoint: CGPointMake(21.41, 285.76)]; 147 | [pathPath addLineToPoint: CGPointMake(14.58, 279.8)]; 148 | [pathPath addLineToPoint: CGPointMake(7.98, 272.26)]; 149 | [pathPath addLineToPoint: CGPointMake(2.44, 265.23)]; 150 | [pathPath addLineToPoint: CGPointMake(0, 261.01)]; 151 | [pathPath addLineToPoint: CGPointMake(5.32, 264.54)]; 152 | [pathPath addLineToPoint: CGPointMake(13.39, 268.86)]; 153 | [pathPath addLineToPoint: CGPointMake(23.49, 272.5)]; 154 | [pathPath addLineToPoint: CGPointMake(34.16, 276.23)]; 155 | [pathPath addLineToPoint: CGPointMake(42.89, 277.81)]; 156 | [pathPath addLineToPoint: CGPointMake(52.34, 278.79)]; 157 | [pathPath addLineToPoint: CGPointMake(62.37, 278.15)]; 158 | [pathPath addLineToPoint: CGPointMake(69.9, 276.34)]; 159 | [pathPath addLineToPoint: CGPointMake(75.19, 275.03)]; 160 | [pathPath addLineToPoint: CGPointMake(84.54, 270.85)]; 161 | [pathPath addLineToPoint: CGPointMake(75.45, 263.98)]; 162 | [pathPath addLineToPoint: CGPointMake(66.72, 256.2)]; 163 | [pathPath addLineToPoint: CGPointMake(54.02, 243.02)]; 164 | [pathPath addLineToPoint: CGPointMake(45.69, 232.94)]; 165 | [pathPath addLineToPoint: CGPointMake(29.86, 214.82)]; 166 | [pathPath addLineToPoint: CGPointMake(14.33, 194.69)]; 167 | [pathPath addLineToPoint: CGPointMake(43.52, 218.64)]; 168 | [pathPath addLineToPoint: CGPointMake(68.3, 236.21)]; 169 | [pathPath addLineToPoint: CGPointMake(73.55, 239.15)]; 170 | [pathPath addLineToPoint: CGPointMake(67.31, 233.13)]; 171 | [pathPath addLineToPoint: CGPointMake(59.18, 223)]; 172 | [pathPath addLineToPoint: CGPointMake(52.13, 214.22)]; 173 | [pathPath addLineToPoint: CGPointMake(43.06, 201.52)]; 174 | [pathPath addLineToPoint: CGPointMake(33.24, 187.6)]; 175 | [pathPath closePath]; 176 | [strokeColor setStroke]; 177 | pathPath.lineWidth = 1; 178 | pathPath.miterLimit = 4; 179 | return pathPath; 180 | } 181 | 182 | @end 183 | -------------------------------------------------------------------------------- /CXProvincesMapView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/4/15. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /CXProvincesMapView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/4/15. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SwiftLaunchView.h" 11 | #import "SampleMapController.h" 12 | 13 | @interface ViewController () 14 | 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | [SwiftLaunchView launchAnimation]; 22 | // Do any additional setup after loading the view. 23 | } 24 | 25 | - (IBAction)mapClick:(id)sender { 26 | 27 | [self.navigationController pushViewController:[SampleMapController new] animated:YES]; 28 | 29 | } 30 | 31 | - (void)viewDidAppear:(BOOL)animated{ 32 | [super viewDidAppear:animated]; 33 | 34 | } 35 | 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /CXProvincesMapView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CXProvincesMapView 4 | // 5 | // Created by Felix on 2019/4/15. 6 | // Copyright © 2019 CXTretar. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 CXTretar 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CXProvincesMapView 2 | ![CXProvincesMapView](https://github.com/CXTretar/CXProvincesMapView/blob/master/gif/province.gif) 3 | 4 | ### 关于自定义 MapPath 的数据获取可以看下这里 [使用 PaintCode 绘制自定义的省份地图控件](https://cxtretar.github.io/2019/10/27/使用-PaintCode-绘制自定义的省份地图控件/) 5 | 6 | # Update【更新】 7 | - 10.17 新增了图钉点击效果,可以添加自定义视图 8 | - 10.22 增加了新的构造方法,提供外部传入 mapPath 参数, 修复了PinView的大小计算Bug,Demo增加了福建省的数据以及视图 9 | 10 | # Install【安装】 11 | 在Podfile文件中添加`pod 'CXProvincesMapView'`,并运行 `pod install` 12 | # Usage【使用】 13 | * import【导入框架】 14 | `#import "CXProvincesMapView.h"` 15 | 16 | * custom【自定义属性】 17 | ``` 18 | @property(nonatomic, assign) NSInteger selectedIndex; // 选中省份的index 19 | @property(nonatomic, strong) UIColor *fillColor; // 省份的背景颜色 20 | @property(nonatomic, strong) UIColor *fillSelectedColor; // 选中省份的背景颜色 21 | @property(nonatomic, strong) UIColor *strokeColor; // 省份边界的颜色 22 | @property(nonatomic, strong) UIColor *strokeSelectedColor; // 选中省份边界的颜色 23 | @property(nonatomic, strong) UIColor *textColor; // 省份字体的颜色 24 | @property(nonatomic, strong) UIColor *textSelectedColor; // 选中省份字体的颜色 25 | 26 | @property(nonatomic, assign) CGFloat minimumZoomScale; // default is 1.0 27 | @property(nonatomic, assign) CGFloat maximumZoomScale; // default is 2.0 28 | 29 | @property(nonatomic, strong) UIView *pinView; // 图钉自定义视图 30 | @property(nonatomic, strong) UIImage *pinImage; // 图钉图片 31 | @property(nonatomic, assign) BOOL pinAnimation; // default is YES 图钉是否动画 32 | 33 | @property(nonatomic, weak) id delegate; 34 | 35 | /// 自定义的地图快捷创建方法 36 | /// @param mapPath svg 绘图数据 37 | /// @param mapSize svg 绘图尺寸 38 | /// @param frame 视图控件的frame 39 | - (instancetype)initWithMapPath:(ChinaMapPath *)mapPath andMapSize:(CGSize)mapSize andFrame:(CGRect)frame; 40 | ``` 41 | * example【示例】 42 | ``` 43 | // 44 | // SampleMapController.m 45 | // CXProvincesMapView 46 | // 47 | // Created by Felix on 2019/4/22. 48 | // Copyright © 2019 CXTretar. All rights reserved. 49 | // 50 | 51 | #import "SampleMapController.h" 52 | #import "CXProvincesMapView.h" 53 | 54 | @interface SampleMapController () 55 | 56 | @property (nonatomic, strong) CXProvincesMapView *chinaMapView; 57 | 58 | @end 59 | 60 | @implementation SampleMapController 61 | 62 | - (void)viewDidLoad { 63 | [super viewDidLoad]; 64 | self.title = @"SampleMapController"; 65 | self.view.backgroundColor = [UIColor whiteColor]; 66 | 67 | 68 | self.chinaMapView = [[CXProvincesMapView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 400)]; 69 | _chinaMapView.backgroundColor = [UIColor colorWithRed:230/255.0 green:1.0 blue:1.0 alpha:1.0]; 70 | _chinaMapView.maximumZoomScale = 5.0; 71 | _chinaMapView.delegate = self; 72 | _chinaMapView.center = self.view.center; 73 | // _chinaMapView.pinAnimation = NO; 74 | // 直接设置图片 75 | // _chinaMapView.pinImage = [UIImage imageNamed:@"pin"]; 76 | // 添加按钮点击 77 | UIButton *pinButton = [[UIButton alloc]initWithFrame:_chinaMapView.pinView.bounds]; 78 | [pinButton setImage:[UIImage imageNamed:@"pin"] forState:UIControlStateNormal]; 79 | [pinButton addTarget:self action:@selector(pinTest) forControlEvents:UIControlEventTouchUpInside]; 80 | [_chinaMapView.pinView addSubview:pinButton]; 81 | 82 | [self.view addSubview:_chinaMapView]; 83 | } 84 | 85 | - (void)viewDidLayoutSubviews { 86 | [super viewDidLayoutSubviews]; 87 | // 88 | if (self.view.bounds.size.width > self.view.bounds.size.height) { 89 | self.chinaMapView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 400); 90 | } else { 91 | self.chinaMapView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 400); 92 | } 93 | self.chinaMapView.center = self.view.center; 94 | } 95 | 96 | - (void)selectProvinceAtIndex:(NSInteger)index andName:(NSString *)name { 97 | NSLog(@"Province - %ld - %@", (long)index, name); 98 | self.title = [NSString stringWithFormat:@"Province - %ld - %@", (long)index, name]; 99 | } 100 | 101 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 102 | _chinaMapView.selectedIndex = 0; 103 | _chinaMapView.fillColor = [UIColor cyanColor]; 104 | _chinaMapView.fillSelectedColor = [UIColor greenColor]; 105 | _chinaMapView.strokeColor = [UIColor whiteColor]; 106 | _chinaMapView.strokeSelectedColor = [UIColor greenColor]; 107 | _chinaMapView.textColor = [UIColor blueColor]; 108 | _chinaMapView.textSelectedColor = [UIColor orangeColor]; 109 | 110 | } 111 | 112 | - (void)pinTest { 113 | NSLog(@"%s", __func__); 114 | } 115 | 116 | - (void)dealloc { 117 | NSLog(@"%s", __func__); 118 | } 119 | 120 | @end 121 | 122 | 123 | ``` 124 | * 自定义的mapPath (mapPath 类继承 ChinaMapPath.h)【示例】 125 | 126 | ``` 127 | - (void)viewDidLoad { 128 | [super viewDidLoad]; 129 | self.view.backgroundColor = [UIColor whiteColor]; 130 | // 福建省市数据 131 | FujianMapPath *mapPath = [[FujianMapPath alloc] init]; 132 | self.chinaMapView = [[CXProvincesMapView alloc]initWithMapPath:mapPath andMapSize:CGSizeMake(308, 340) andFrame:CGRectMake(0, 0, self.view.bounds.size.width, 400)]; 133 | _chinaMapView.backgroundColor = [UIColor colorWithRed:230/255.0 green:1.0 blue:1.0 alpha:1.0]; 134 | _chinaMapView.maximumZoomScale = 5.0; 135 | _chinaMapView.center = self.view.center; 136 | _chinaMapView.delegate = self; 137 | // _chinaMapView.pinAnimation = NO; 138 | // 直接设置图片 139 | // _chinaMapView.pinImage = [UIImage imageNamed:@"pin"]; 140 | // 添加按钮点击 141 | UIButton *pinButton = [[UIButton alloc]initWithFrame:_chinaMapView.pinView.bounds]; 142 | [pinButton setImage:[UIImage imageNamed:@"pin"] forState:UIControlStateNormal]; 143 | [pinButton addTarget:self action:@selector(pinTest) forControlEvents:UIControlEventTouchUpInside]; 144 | [_chinaMapView.pinView addSubview:pinButton]; 145 | [self.view addSubview:_chinaMapView]; 146 | } 147 | 148 | ``` 149 | 150 | -------------------------------------------------------------------------------- /gif/province.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CXTretar/CXProvincesMapView/5c3b284b460fdf60784a01af17c74b12ff975985/gif/province.gif --------------------------------------------------------------------------------