├── .gitignore ├── CustomDemo ├── CustomDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── CustomDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── UIButton+Extension.h │ ├── UIButton+Extension.m │ ├── ViewController.h │ ├── ViewController.m │ ├── collect_icon.png │ └── main.m ├── CustomDemoTests │ ├── CustomDemoTests.m │ └── Info.plist └── CustomDemoUITests │ ├── CustomDemoUITests.m │ └── Info.plist ├── README.md └── 效果图.jpg /.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 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0A36A8EF219BB90300BABFB3 /* UIButton+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A36A8EE219BB90300BABFB3 /* UIButton+Extension.m */; }; 11 | 0A909A80219ADA3400B8AE1E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A909A7F219ADA3400B8AE1E /* AppDelegate.m */; }; 12 | 0A909A83219ADA3400B8AE1E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A909A82219ADA3400B8AE1E /* ViewController.m */; }; 13 | 0A909A86219ADA3400B8AE1E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A909A84219ADA3400B8AE1E /* Main.storyboard */; }; 14 | 0A909A88219ADA3500B8AE1E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A909A87219ADA3500B8AE1E /* Assets.xcassets */; }; 15 | 0A909A8B219ADA3500B8AE1E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A909A89219ADA3500B8AE1E /* LaunchScreen.storyboard */; }; 16 | 0A909A8E219ADA3500B8AE1E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A909A8D219ADA3500B8AE1E /* main.m */; }; 17 | 0A909A98219ADA3600B8AE1E /* CustomDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A909A97219ADA3600B8AE1E /* CustomDemoTests.m */; }; 18 | 0A909AA3219ADA3600B8AE1E /* CustomDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A909AA2219ADA3600B8AE1E /* CustomDemoUITests.m */; }; 19 | 0A909AB1219ADAA900B8AE1E /* collect_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 0A909AB0219ADAA900B8AE1E /* collect_icon.png */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 0A909A94219ADA3600B8AE1E /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 0A909A73219ADA3400B8AE1E /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 0A909A7A219ADA3400B8AE1E; 28 | remoteInfo = CustomDemo; 29 | }; 30 | 0A909A9F219ADA3600B8AE1E /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 0A909A73219ADA3400B8AE1E /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 0A909A7A219ADA3400B8AE1E; 35 | remoteInfo = CustomDemo; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 0A36A8ED219BB90300BABFB3 /* UIButton+Extension.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIButton+Extension.h"; sourceTree = ""; }; 41 | 0A36A8EE219BB90300BABFB3 /* UIButton+Extension.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIButton+Extension.m"; sourceTree = ""; }; 42 | 0A909A7B219ADA3400B8AE1E /* CustomDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CustomDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 0A909A7E219ADA3400B8AE1E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 44 | 0A909A7F219ADA3400B8AE1E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 45 | 0A909A81219ADA3400B8AE1E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 46 | 0A909A82219ADA3400B8AE1E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 47 | 0A909A85219ADA3400B8AE1E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 48 | 0A909A87219ADA3500B8AE1E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 49 | 0A909A8A219ADA3500B8AE1E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 50 | 0A909A8C219ADA3500B8AE1E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | 0A909A8D219ADA3500B8AE1E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 52 | 0A909A93219ADA3600B8AE1E /* CustomDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CustomDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 0A909A97219ADA3600B8AE1E /* CustomDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CustomDemoTests.m; sourceTree = ""; }; 54 | 0A909A99219ADA3600B8AE1E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 0A909A9E219ADA3600B8AE1E /* CustomDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CustomDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | 0A909AA2219ADA3600B8AE1E /* CustomDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CustomDemoUITests.m; sourceTree = ""; }; 57 | 0A909AA4219ADA3600B8AE1E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 58 | 0A909AB0219ADAA900B8AE1E /* collect_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = collect_icon.png; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | 0A909A78219ADA3400B8AE1E /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | 0A909A90219ADA3600B8AE1E /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | 0A909A9B219ADA3600B8AE1E /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | /* End PBXFrameworksBuildPhase section */ 84 | 85 | /* Begin PBXGroup section */ 86 | 0A909A72219ADA3400B8AE1E = { 87 | isa = PBXGroup; 88 | children = ( 89 | 0A909A7D219ADA3400B8AE1E /* CustomDemo */, 90 | 0A909A96219ADA3600B8AE1E /* CustomDemoTests */, 91 | 0A909AA1219ADA3600B8AE1E /* CustomDemoUITests */, 92 | 0A909A7C219ADA3400B8AE1E /* Products */, 93 | ); 94 | sourceTree = ""; 95 | }; 96 | 0A909A7C219ADA3400B8AE1E /* Products */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 0A909A7B219ADA3400B8AE1E /* CustomDemo.app */, 100 | 0A909A93219ADA3600B8AE1E /* CustomDemoTests.xctest */, 101 | 0A909A9E219ADA3600B8AE1E /* CustomDemoUITests.xctest */, 102 | ); 103 | name = Products; 104 | sourceTree = ""; 105 | }; 106 | 0A909A7D219ADA3400B8AE1E /* CustomDemo */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 0A909AB0219ADAA900B8AE1E /* collect_icon.png */, 110 | 0A909A7E219ADA3400B8AE1E /* AppDelegate.h */, 111 | 0A909A7F219ADA3400B8AE1E /* AppDelegate.m */, 112 | 0A909A81219ADA3400B8AE1E /* ViewController.h */, 113 | 0A909A82219ADA3400B8AE1E /* ViewController.m */, 114 | 0A36A8ED219BB90300BABFB3 /* UIButton+Extension.h */, 115 | 0A36A8EE219BB90300BABFB3 /* UIButton+Extension.m */, 116 | 0A909A84219ADA3400B8AE1E /* Main.storyboard */, 117 | 0A909A87219ADA3500B8AE1E /* Assets.xcassets */, 118 | 0A909A89219ADA3500B8AE1E /* LaunchScreen.storyboard */, 119 | 0A909A8C219ADA3500B8AE1E /* Info.plist */, 120 | 0A909A8D219ADA3500B8AE1E /* main.m */, 121 | ); 122 | path = CustomDemo; 123 | sourceTree = ""; 124 | }; 125 | 0A909A96219ADA3600B8AE1E /* CustomDemoTests */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 0A909A97219ADA3600B8AE1E /* CustomDemoTests.m */, 129 | 0A909A99219ADA3600B8AE1E /* Info.plist */, 130 | ); 131 | path = CustomDemoTests; 132 | sourceTree = ""; 133 | }; 134 | 0A909AA1219ADA3600B8AE1E /* CustomDemoUITests */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 0A909AA2219ADA3600B8AE1E /* CustomDemoUITests.m */, 138 | 0A909AA4219ADA3600B8AE1E /* Info.plist */, 139 | ); 140 | path = CustomDemoUITests; 141 | sourceTree = ""; 142 | }; 143 | /* End PBXGroup section */ 144 | 145 | /* Begin PBXNativeTarget section */ 146 | 0A909A7A219ADA3400B8AE1E /* CustomDemo */ = { 147 | isa = PBXNativeTarget; 148 | buildConfigurationList = 0A909AA7219ADA3600B8AE1E /* Build configuration list for PBXNativeTarget "CustomDemo" */; 149 | buildPhases = ( 150 | 0A909A77219ADA3400B8AE1E /* Sources */, 151 | 0A909A78219ADA3400B8AE1E /* Frameworks */, 152 | 0A909A79219ADA3400B8AE1E /* Resources */, 153 | ); 154 | buildRules = ( 155 | ); 156 | dependencies = ( 157 | ); 158 | name = CustomDemo; 159 | productName = CustomDemo; 160 | productReference = 0A909A7B219ADA3400B8AE1E /* CustomDemo.app */; 161 | productType = "com.apple.product-type.application"; 162 | }; 163 | 0A909A92219ADA3600B8AE1E /* CustomDemoTests */ = { 164 | isa = PBXNativeTarget; 165 | buildConfigurationList = 0A909AAA219ADA3600B8AE1E /* Build configuration list for PBXNativeTarget "CustomDemoTests" */; 166 | buildPhases = ( 167 | 0A909A8F219ADA3600B8AE1E /* Sources */, 168 | 0A909A90219ADA3600B8AE1E /* Frameworks */, 169 | 0A909A91219ADA3600B8AE1E /* Resources */, 170 | ); 171 | buildRules = ( 172 | ); 173 | dependencies = ( 174 | 0A909A95219ADA3600B8AE1E /* PBXTargetDependency */, 175 | ); 176 | name = CustomDemoTests; 177 | productName = CustomDemoTests; 178 | productReference = 0A909A93219ADA3600B8AE1E /* CustomDemoTests.xctest */; 179 | productType = "com.apple.product-type.bundle.unit-test"; 180 | }; 181 | 0A909A9D219ADA3600B8AE1E /* CustomDemoUITests */ = { 182 | isa = PBXNativeTarget; 183 | buildConfigurationList = 0A909AAD219ADA3600B8AE1E /* Build configuration list for PBXNativeTarget "CustomDemoUITests" */; 184 | buildPhases = ( 185 | 0A909A9A219ADA3600B8AE1E /* Sources */, 186 | 0A909A9B219ADA3600B8AE1E /* Frameworks */, 187 | 0A909A9C219ADA3600B8AE1E /* Resources */, 188 | ); 189 | buildRules = ( 190 | ); 191 | dependencies = ( 192 | 0A909AA0219ADA3600B8AE1E /* PBXTargetDependency */, 193 | ); 194 | name = CustomDemoUITests; 195 | productName = CustomDemoUITests; 196 | productReference = 0A909A9E219ADA3600B8AE1E /* CustomDemoUITests.xctest */; 197 | productType = "com.apple.product-type.bundle.ui-testing"; 198 | }; 199 | /* End PBXNativeTarget section */ 200 | 201 | /* Begin PBXProject section */ 202 | 0A909A73219ADA3400B8AE1E /* Project object */ = { 203 | isa = PBXProject; 204 | attributes = { 205 | LastUpgradeCheck = 0930; 206 | ORGANIZATIONNAME = "尾灯"; 207 | TargetAttributes = { 208 | 0A909A7A219ADA3400B8AE1E = { 209 | CreatedOnToolsVersion = 9.3; 210 | }; 211 | 0A909A92219ADA3600B8AE1E = { 212 | CreatedOnToolsVersion = 9.3; 213 | TestTargetID = 0A909A7A219ADA3400B8AE1E; 214 | }; 215 | 0A909A9D219ADA3600B8AE1E = { 216 | CreatedOnToolsVersion = 9.3; 217 | TestTargetID = 0A909A7A219ADA3400B8AE1E; 218 | }; 219 | }; 220 | }; 221 | buildConfigurationList = 0A909A76219ADA3400B8AE1E /* Build configuration list for PBXProject "CustomDemo" */; 222 | compatibilityVersion = "Xcode 9.3"; 223 | developmentRegion = en; 224 | hasScannedForEncodings = 0; 225 | knownRegions = ( 226 | en, 227 | Base, 228 | ); 229 | mainGroup = 0A909A72219ADA3400B8AE1E; 230 | productRefGroup = 0A909A7C219ADA3400B8AE1E /* Products */; 231 | projectDirPath = ""; 232 | projectRoot = ""; 233 | targets = ( 234 | 0A909A7A219ADA3400B8AE1E /* CustomDemo */, 235 | 0A909A92219ADA3600B8AE1E /* CustomDemoTests */, 236 | 0A909A9D219ADA3600B8AE1E /* CustomDemoUITests */, 237 | ); 238 | }; 239 | /* End PBXProject section */ 240 | 241 | /* Begin PBXResourcesBuildPhase section */ 242 | 0A909A79219ADA3400B8AE1E /* Resources */ = { 243 | isa = PBXResourcesBuildPhase; 244 | buildActionMask = 2147483647; 245 | files = ( 246 | 0A909A8B219ADA3500B8AE1E /* LaunchScreen.storyboard in Resources */, 247 | 0A909AB1219ADAA900B8AE1E /* collect_icon.png in Resources */, 248 | 0A909A88219ADA3500B8AE1E /* Assets.xcassets in Resources */, 249 | 0A909A86219ADA3400B8AE1E /* Main.storyboard in Resources */, 250 | ); 251 | runOnlyForDeploymentPostprocessing = 0; 252 | }; 253 | 0A909A91219ADA3600B8AE1E /* Resources */ = { 254 | isa = PBXResourcesBuildPhase; 255 | buildActionMask = 2147483647; 256 | files = ( 257 | ); 258 | runOnlyForDeploymentPostprocessing = 0; 259 | }; 260 | 0A909A9C219ADA3600B8AE1E /* Resources */ = { 261 | isa = PBXResourcesBuildPhase; 262 | buildActionMask = 2147483647; 263 | files = ( 264 | ); 265 | runOnlyForDeploymentPostprocessing = 0; 266 | }; 267 | /* End PBXResourcesBuildPhase section */ 268 | 269 | /* Begin PBXSourcesBuildPhase section */ 270 | 0A909A77219ADA3400B8AE1E /* Sources */ = { 271 | isa = PBXSourcesBuildPhase; 272 | buildActionMask = 2147483647; 273 | files = ( 274 | 0A909A83219ADA3400B8AE1E /* ViewController.m in Sources */, 275 | 0A36A8EF219BB90300BABFB3 /* UIButton+Extension.m in Sources */, 276 | 0A909A8E219ADA3500B8AE1E /* main.m in Sources */, 277 | 0A909A80219ADA3400B8AE1E /* AppDelegate.m in Sources */, 278 | ); 279 | runOnlyForDeploymentPostprocessing = 0; 280 | }; 281 | 0A909A8F219ADA3600B8AE1E /* Sources */ = { 282 | isa = PBXSourcesBuildPhase; 283 | buildActionMask = 2147483647; 284 | files = ( 285 | 0A909A98219ADA3600B8AE1E /* CustomDemoTests.m in Sources */, 286 | ); 287 | runOnlyForDeploymentPostprocessing = 0; 288 | }; 289 | 0A909A9A219ADA3600B8AE1E /* Sources */ = { 290 | isa = PBXSourcesBuildPhase; 291 | buildActionMask = 2147483647; 292 | files = ( 293 | 0A909AA3219ADA3600B8AE1E /* CustomDemoUITests.m in Sources */, 294 | ); 295 | runOnlyForDeploymentPostprocessing = 0; 296 | }; 297 | /* End PBXSourcesBuildPhase section */ 298 | 299 | /* Begin PBXTargetDependency section */ 300 | 0A909A95219ADA3600B8AE1E /* PBXTargetDependency */ = { 301 | isa = PBXTargetDependency; 302 | target = 0A909A7A219ADA3400B8AE1E /* CustomDemo */; 303 | targetProxy = 0A909A94219ADA3600B8AE1E /* PBXContainerItemProxy */; 304 | }; 305 | 0A909AA0219ADA3600B8AE1E /* PBXTargetDependency */ = { 306 | isa = PBXTargetDependency; 307 | target = 0A909A7A219ADA3400B8AE1E /* CustomDemo */; 308 | targetProxy = 0A909A9F219ADA3600B8AE1E /* PBXContainerItemProxy */; 309 | }; 310 | /* End PBXTargetDependency section */ 311 | 312 | /* Begin PBXVariantGroup section */ 313 | 0A909A84219ADA3400B8AE1E /* Main.storyboard */ = { 314 | isa = PBXVariantGroup; 315 | children = ( 316 | 0A909A85219ADA3400B8AE1E /* Base */, 317 | ); 318 | name = Main.storyboard; 319 | sourceTree = ""; 320 | }; 321 | 0A909A89219ADA3500B8AE1E /* LaunchScreen.storyboard */ = { 322 | isa = PBXVariantGroup; 323 | children = ( 324 | 0A909A8A219ADA3500B8AE1E /* Base */, 325 | ); 326 | name = LaunchScreen.storyboard; 327 | sourceTree = ""; 328 | }; 329 | /* End PBXVariantGroup section */ 330 | 331 | /* Begin XCBuildConfiguration section */ 332 | 0A909AA5219ADA3600B8AE1E /* Debug */ = { 333 | isa = XCBuildConfiguration; 334 | buildSettings = { 335 | ALWAYS_SEARCH_USER_PATHS = NO; 336 | CLANG_ANALYZER_NONNULL = YES; 337 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 338 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 339 | CLANG_CXX_LIBRARY = "libc++"; 340 | CLANG_ENABLE_MODULES = YES; 341 | CLANG_ENABLE_OBJC_ARC = YES; 342 | CLANG_ENABLE_OBJC_WEAK = YES; 343 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 344 | CLANG_WARN_BOOL_CONVERSION = YES; 345 | CLANG_WARN_COMMA = YES; 346 | CLANG_WARN_CONSTANT_CONVERSION = YES; 347 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 348 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 349 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 350 | CLANG_WARN_EMPTY_BODY = YES; 351 | CLANG_WARN_ENUM_CONVERSION = YES; 352 | CLANG_WARN_INFINITE_RECURSION = YES; 353 | CLANG_WARN_INT_CONVERSION = YES; 354 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 355 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 356 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 357 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 358 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 359 | CLANG_WARN_STRICT_PROTOTYPES = YES; 360 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 361 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 362 | CLANG_WARN_UNREACHABLE_CODE = YES; 363 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 364 | CODE_SIGN_IDENTITY = "iPhone Developer"; 365 | COPY_PHASE_STRIP = NO; 366 | DEBUG_INFORMATION_FORMAT = dwarf; 367 | ENABLE_STRICT_OBJC_MSGSEND = YES; 368 | ENABLE_TESTABILITY = YES; 369 | GCC_C_LANGUAGE_STANDARD = gnu11; 370 | GCC_DYNAMIC_NO_PIC = NO; 371 | GCC_NO_COMMON_BLOCKS = YES; 372 | GCC_OPTIMIZATION_LEVEL = 0; 373 | GCC_PREPROCESSOR_DEFINITIONS = ( 374 | "DEBUG=1", 375 | "$(inherited)", 376 | ); 377 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 378 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 379 | GCC_WARN_UNDECLARED_SELECTOR = YES; 380 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 381 | GCC_WARN_UNUSED_FUNCTION = YES; 382 | GCC_WARN_UNUSED_VARIABLE = YES; 383 | IPHONEOS_DEPLOYMENT_TARGET = 11.3; 384 | MTL_ENABLE_DEBUG_INFO = YES; 385 | ONLY_ACTIVE_ARCH = YES; 386 | SDKROOT = iphoneos; 387 | }; 388 | name = Debug; 389 | }; 390 | 0A909AA6219ADA3600B8AE1E /* Release */ = { 391 | isa = XCBuildConfiguration; 392 | buildSettings = { 393 | ALWAYS_SEARCH_USER_PATHS = NO; 394 | CLANG_ANALYZER_NONNULL = YES; 395 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 396 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 397 | CLANG_CXX_LIBRARY = "libc++"; 398 | CLANG_ENABLE_MODULES = YES; 399 | CLANG_ENABLE_OBJC_ARC = YES; 400 | CLANG_ENABLE_OBJC_WEAK = YES; 401 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 402 | CLANG_WARN_BOOL_CONVERSION = YES; 403 | CLANG_WARN_COMMA = YES; 404 | CLANG_WARN_CONSTANT_CONVERSION = YES; 405 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 406 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 407 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 408 | CLANG_WARN_EMPTY_BODY = YES; 409 | CLANG_WARN_ENUM_CONVERSION = YES; 410 | CLANG_WARN_INFINITE_RECURSION = YES; 411 | CLANG_WARN_INT_CONVERSION = YES; 412 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 413 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 414 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 415 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 416 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 417 | CLANG_WARN_STRICT_PROTOTYPES = YES; 418 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 419 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 420 | CLANG_WARN_UNREACHABLE_CODE = YES; 421 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 422 | CODE_SIGN_IDENTITY = "iPhone Developer"; 423 | COPY_PHASE_STRIP = NO; 424 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 425 | ENABLE_NS_ASSERTIONS = NO; 426 | ENABLE_STRICT_OBJC_MSGSEND = YES; 427 | GCC_C_LANGUAGE_STANDARD = gnu11; 428 | GCC_NO_COMMON_BLOCKS = YES; 429 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 430 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 431 | GCC_WARN_UNDECLARED_SELECTOR = YES; 432 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 433 | GCC_WARN_UNUSED_FUNCTION = YES; 434 | GCC_WARN_UNUSED_VARIABLE = YES; 435 | IPHONEOS_DEPLOYMENT_TARGET = 11.3; 436 | MTL_ENABLE_DEBUG_INFO = NO; 437 | SDKROOT = iphoneos; 438 | VALIDATE_PRODUCT = YES; 439 | }; 440 | name = Release; 441 | }; 442 | 0A909AA8219ADA3600B8AE1E /* Debug */ = { 443 | isa = XCBuildConfiguration; 444 | buildSettings = { 445 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 446 | CODE_SIGN_STYLE = Automatic; 447 | DEVELOPMENT_TEAM = XFV7U624AZ; 448 | INFOPLIST_FILE = CustomDemo/Info.plist; 449 | LD_RUNPATH_SEARCH_PATHS = ( 450 | "$(inherited)", 451 | "@executable_path/Frameworks", 452 | ); 453 | PRODUCT_BUNDLE_IDENTIFIER = com.quickpark.CustomDemo; 454 | PRODUCT_NAME = "$(TARGET_NAME)"; 455 | TARGETED_DEVICE_FAMILY = "1,2"; 456 | }; 457 | name = Debug; 458 | }; 459 | 0A909AA9219ADA3600B8AE1E /* Release */ = { 460 | isa = XCBuildConfiguration; 461 | buildSettings = { 462 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 463 | CODE_SIGN_STYLE = Automatic; 464 | DEVELOPMENT_TEAM = XFV7U624AZ; 465 | INFOPLIST_FILE = CustomDemo/Info.plist; 466 | LD_RUNPATH_SEARCH_PATHS = ( 467 | "$(inherited)", 468 | "@executable_path/Frameworks", 469 | ); 470 | PRODUCT_BUNDLE_IDENTIFIER = com.quickpark.CustomDemo; 471 | PRODUCT_NAME = "$(TARGET_NAME)"; 472 | TARGETED_DEVICE_FAMILY = "1,2"; 473 | }; 474 | name = Release; 475 | }; 476 | 0A909AAB219ADA3600B8AE1E /* Debug */ = { 477 | isa = XCBuildConfiguration; 478 | buildSettings = { 479 | BUNDLE_LOADER = "$(TEST_HOST)"; 480 | CODE_SIGN_STYLE = Automatic; 481 | DEVELOPMENT_TEAM = XFV7U624AZ; 482 | INFOPLIST_FILE = CustomDemoTests/Info.plist; 483 | LD_RUNPATH_SEARCH_PATHS = ( 484 | "$(inherited)", 485 | "@executable_path/Frameworks", 486 | "@loader_path/Frameworks", 487 | ); 488 | PRODUCT_BUNDLE_IDENTIFIER = com.quickpark.CustomDemoTests; 489 | PRODUCT_NAME = "$(TARGET_NAME)"; 490 | TARGETED_DEVICE_FAMILY = "1,2"; 491 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CustomDemo.app/CustomDemo"; 492 | }; 493 | name = Debug; 494 | }; 495 | 0A909AAC219ADA3600B8AE1E /* Release */ = { 496 | isa = XCBuildConfiguration; 497 | buildSettings = { 498 | BUNDLE_LOADER = "$(TEST_HOST)"; 499 | CODE_SIGN_STYLE = Automatic; 500 | DEVELOPMENT_TEAM = XFV7U624AZ; 501 | INFOPLIST_FILE = CustomDemoTests/Info.plist; 502 | LD_RUNPATH_SEARCH_PATHS = ( 503 | "$(inherited)", 504 | "@executable_path/Frameworks", 505 | "@loader_path/Frameworks", 506 | ); 507 | PRODUCT_BUNDLE_IDENTIFIER = com.quickpark.CustomDemoTests; 508 | PRODUCT_NAME = "$(TARGET_NAME)"; 509 | TARGETED_DEVICE_FAMILY = "1,2"; 510 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CustomDemo.app/CustomDemo"; 511 | }; 512 | name = Release; 513 | }; 514 | 0A909AAE219ADA3600B8AE1E /* Debug */ = { 515 | isa = XCBuildConfiguration; 516 | buildSettings = { 517 | CODE_SIGN_STYLE = Automatic; 518 | DEVELOPMENT_TEAM = XFV7U624AZ; 519 | INFOPLIST_FILE = CustomDemoUITests/Info.plist; 520 | LD_RUNPATH_SEARCH_PATHS = ( 521 | "$(inherited)", 522 | "@executable_path/Frameworks", 523 | "@loader_path/Frameworks", 524 | ); 525 | PRODUCT_BUNDLE_IDENTIFIER = com.quickpark.CustomDemoUITests; 526 | PRODUCT_NAME = "$(TARGET_NAME)"; 527 | TARGETED_DEVICE_FAMILY = "1,2"; 528 | TEST_TARGET_NAME = CustomDemo; 529 | }; 530 | name = Debug; 531 | }; 532 | 0A909AAF219ADA3600B8AE1E /* Release */ = { 533 | isa = XCBuildConfiguration; 534 | buildSettings = { 535 | CODE_SIGN_STYLE = Automatic; 536 | DEVELOPMENT_TEAM = XFV7U624AZ; 537 | INFOPLIST_FILE = CustomDemoUITests/Info.plist; 538 | LD_RUNPATH_SEARCH_PATHS = ( 539 | "$(inherited)", 540 | "@executable_path/Frameworks", 541 | "@loader_path/Frameworks", 542 | ); 543 | PRODUCT_BUNDLE_IDENTIFIER = com.quickpark.CustomDemoUITests; 544 | PRODUCT_NAME = "$(TARGET_NAME)"; 545 | TARGETED_DEVICE_FAMILY = "1,2"; 546 | TEST_TARGET_NAME = CustomDemo; 547 | }; 548 | name = Release; 549 | }; 550 | /* End XCBuildConfiguration section */ 551 | 552 | /* Begin XCConfigurationList section */ 553 | 0A909A76219ADA3400B8AE1E /* Build configuration list for PBXProject "CustomDemo" */ = { 554 | isa = XCConfigurationList; 555 | buildConfigurations = ( 556 | 0A909AA5219ADA3600B8AE1E /* Debug */, 557 | 0A909AA6219ADA3600B8AE1E /* Release */, 558 | ); 559 | defaultConfigurationIsVisible = 0; 560 | defaultConfigurationName = Release; 561 | }; 562 | 0A909AA7219ADA3600B8AE1E /* Build configuration list for PBXNativeTarget "CustomDemo" */ = { 563 | isa = XCConfigurationList; 564 | buildConfigurations = ( 565 | 0A909AA8219ADA3600B8AE1E /* Debug */, 566 | 0A909AA9219ADA3600B8AE1E /* Release */, 567 | ); 568 | defaultConfigurationIsVisible = 0; 569 | defaultConfigurationName = Release; 570 | }; 571 | 0A909AAA219ADA3600B8AE1E /* Build configuration list for PBXNativeTarget "CustomDemoTests" */ = { 572 | isa = XCConfigurationList; 573 | buildConfigurations = ( 574 | 0A909AAB219ADA3600B8AE1E /* Debug */, 575 | 0A909AAC219ADA3600B8AE1E /* Release */, 576 | ); 577 | defaultConfigurationIsVisible = 0; 578 | defaultConfigurationName = Release; 579 | }; 580 | 0A909AAD219ADA3600B8AE1E /* Build configuration list for PBXNativeTarget "CustomDemoUITests" */ = { 581 | isa = XCConfigurationList; 582 | buildConfigurations = ( 583 | 0A909AAE219ADA3600B8AE1E /* Debug */, 584 | 0A909AAF219ADA3600B8AE1E /* Release */, 585 | ); 586 | defaultConfigurationIsVisible = 0; 587 | defaultConfigurationName = Release; 588 | }; 589 | /* End XCConfigurationList section */ 590 | }; 591 | rootObject = 0A909A73219ADA3400B8AE1E /* Project object */; 592 | } 593 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CustomDemo 4 | // 5 | // Created by 尾灯 on 2018/11/13. 6 | // Copyright © 2018 尾灯. 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 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CustomDemo 4 | // 5 | // Created by 尾灯 on 2018/11/13. 6 | // Copyright © 2018 尾灯. 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 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/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 | } -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/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 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/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 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/UIButton+Extension.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+Extension.h 3 | // CustomDemo 4 | // 5 | // Created by 尾灯 on 2018/11/14. 6 | // Copyright © 2018 尾灯. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSInteger, ZJButtonImageStyle){ 12 | ZJButtonImageStyleTop = 0, //图片在上,文字在下 13 | ZJButtonImageStyleLeft, //图片在左,文字在右 14 | ZJButtonImageStyleBottom, //图片在下,文字在上 15 | ZJButtonImageStyleRight //图片在右,文字在左 16 | }; 17 | 18 | @interface UIButton (Extension) 19 | 20 | 21 | /** 22 | 设置button的imageView和titleLabel的布局样式及它们的间距 23 | 24 | @param style imageView和titleLabel的布局样式 25 | @param space imageView和titleLabel的间距 26 | */ 27 | - (void)layoutButtonWithImageStyle:(ZJButtonImageStyle)style 28 | imageTitleToSpace:(CGFloat)space; 29 | 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/UIButton+Extension.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+Extension.m 3 | // CustomDemo 4 | // 5 | // Created by 尾灯 on 2018/11/14. 6 | // Copyright © 2018 尾灯. All rights reserved. 7 | // 8 | 9 | #import "UIButton+Extension.h" 10 | 11 | @implementation UIButton (Extension) 12 | 13 | - (void)layoutButtonWithImageStyle:(ZJButtonImageStyle)style imageTitleToSpace:(CGFloat)space 14 | { 15 | //1、获取imageView和titleLabel的高和宽 16 | CGFloat imageWidth = self.imageView.frame.size.width; 17 | CGFloat imageHeight = self.imageView.frame.size.height; 18 | CGFloat titleWidth = self.titleLabel.frame.size.width; 19 | CGFloat titleHeight = self.titleLabel.frame.size.height; 20 | 21 | //2、初始化一个内偏移 22 | UIEdgeInsets imageEdgeInsets = UIEdgeInsetsZero; 23 | UIEdgeInsets titleEdgeInsets = UIEdgeInsetsZero; 24 | 25 | //3、不同的样式处理不同的内偏移 26 | switch (style) { 27 | case ZJButtonImageStyleTop: 28 | imageEdgeInsets = UIEdgeInsetsMake(0, 0, titleHeight + space / 2, -titleWidth); 29 | titleEdgeInsets = UIEdgeInsetsMake(imageHeight + space / 2, -imageWidth, 0, 0); 30 | break; 31 | case ZJButtonImageStyleLeft: 32 | imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, space / 2); 33 | titleEdgeInsets = UIEdgeInsetsMake(0, space / 2, 0, 0); 34 | break; 35 | case ZJButtonImageStyleBottom: 36 | imageEdgeInsets = UIEdgeInsetsMake(titleHeight + space / 2, 0, 0, -titleWidth); 37 | titleEdgeInsets = UIEdgeInsetsMake(0, -imageWidth, imageHeight + space / 2, 0); 38 | break; 39 | case ZJButtonImageStyleRight: 40 | imageEdgeInsets = UIEdgeInsetsMake(0, titleWidth + space / 2, 0, -titleWidth); 41 | titleEdgeInsets = UIEdgeInsetsMake(0, -imageWidth - space / 2, 0, imageWidth); 42 | break; 43 | default: 44 | break; 45 | } 46 | //4、赋值 47 | self.imageEdgeInsets = imageEdgeInsets; 48 | self.titleEdgeInsets = titleEdgeInsets; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CustomDemo 4 | // 5 | // Created by 尾灯 on 2018/11/13. 6 | // Copyright © 2018 尾灯. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CustomDemo 4 | // 5 | // Created by 尾灯 on 2018/11/13. 6 | // Copyright © 2018 尾灯. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "UIButton+Extension.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | [self button1]; 22 | [self button2]; 23 | [self button3]; 24 | [self button4]; 25 | } 26 | //图片在左边 27 | - (void)button1 28 | { 29 | UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 30 | btn.frame = CGRectMake(100, 50, 100, 50); 31 | btn.backgroundColor = [UIColor greenColor]; 32 | [btn setTitle:@"收藏" forState:UIControlStateNormal]; 33 | [btn setImage:[UIImage imageNamed:@"collect_icon"] forState:UIControlStateNormal]; 34 | [btn layoutButtonWithImageStyle:ZJButtonImageStyleLeft imageTitleToSpace:10]; 35 | [self.view addSubview:btn]; 36 | } 37 | //图片在右边 38 | - (void)button2 39 | { 40 | UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 41 | btn.frame = CGRectMake(100, 150, 100, 50); 42 | btn.backgroundColor = [UIColor greenColor]; 43 | [btn setTitle:@"收藏" forState:UIControlStateNormal]; 44 | [btn setImage:[UIImage imageNamed:@"collect_icon"] forState:UIControlStateNormal]; 45 | [btn layoutButtonWithImageStyle:ZJButtonImageStyleRight imageTitleToSpace:10]; 46 | [self.view addSubview:btn]; 47 | } 48 | //图片在上面 49 | - (void)button3 50 | { 51 | UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 52 | btn.frame = CGRectMake(100, 250, 100, 100); 53 | btn.backgroundColor = [UIColor greenColor]; 54 | [btn setTitle:@"收藏" forState:UIControlStateNormal]; 55 | [btn setImage:[UIImage imageNamed:@"collect_icon"] forState:UIControlStateNormal]; 56 | [btn layoutButtonWithImageStyle:ZJButtonImageStyleTop imageTitleToSpace:10]; 57 | [self.view addSubview:btn]; 58 | } 59 | //图片在下面 60 | - (void)button4 61 | { 62 | UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 63 | btn.frame = CGRectMake(100, 400, 100, 100); 64 | btn.backgroundColor = [UIColor greenColor]; 65 | [btn setTitle:@"收藏" forState:UIControlStateNormal]; 66 | [btn setImage:[UIImage imageNamed:@"collect_icon"] forState:UIControlStateNormal]; 67 | [btn layoutButtonWithImageStyle:ZJButtonImageStyleBottom imageTitleToSpace:10]; 68 | [self.view addSubview:btn]; 69 | } 70 | - (void)didReceiveMemoryWarning { 71 | [super didReceiveMemoryWarning]; 72 | // Dispose of any resources that can be recreated. 73 | } 74 | 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/collect_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coder-ZJ/ZJCustomButton/9a8e709658ddc71b9505deaec0e4842207cec092/CustomDemo/CustomDemo/collect_icon.png -------------------------------------------------------------------------------- /CustomDemo/CustomDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CustomDemo 4 | // 5 | // Created by 尾灯 on 2018/11/13. 6 | // Copyright © 2018 尾灯. 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 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemoTests/CustomDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomDemoTests.m 3 | // CustomDemoTests 4 | // 5 | // Created by 尾灯 on 2018/11/13. 6 | // Copyright © 2018 尾灯. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CustomDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CustomDemoTests 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 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemoUITests/CustomDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomDemoUITests.m 3 | // CustomDemoUITests 4 | // 5 | // Created by 尾灯 on 2018/11/13. 6 | // Copyright © 2018 尾灯. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CustomDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CustomDemoUITests 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 | -------------------------------------------------------------------------------- /CustomDemo/CustomDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZJCustomButton 2 | UIButton的一个分类,可在Button里自定义image和title的位置和间距 3 | 效果图: 4 | ![](效果图.jpg) 5 | -------------------------------------------------------------------------------- /效果图.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coder-ZJ/ZJCustomButton/9a8e709658ddc71b9505deaec0e4842207cec092/效果图.jpg --------------------------------------------------------------------------------