├── .gitignore ├── LICENSE ├── NGUIButtonInsetsExample.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── noahgilmore.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── NGUIButtonInsetsExample ├── AppDelegate.swift ├── Artboard.png ├── Artboard@2x.png ├── Artboard@3x.png ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── image.imageset │ │ ├── Artboard.png │ │ ├── Artboard@2x.png │ │ ├── Artboard@3x.png │ │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard ├── Info.plist └── ViewController.swift └── README.md /.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 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | 51 | # Carthage 52 | # 53 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 54 | # Carthage/Checkouts 55 | 56 | Carthage/Build 57 | 58 | # fastlane 59 | # 60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 61 | # screenshots whenever they are needed. 62 | # For more information about the recommended setup visit: 63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 64 | 65 | fastlane/report.xml 66 | fastlane/Preview.html 67 | fastlane/screenshots/**/*.png 68 | fastlane/test_output 69 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Noah Gilmore 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 | -------------------------------------------------------------------------------- /NGUIButtonInsetsExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A11B95242268E2190049EFC8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A11B95232268E2190049EFC8 /* AppDelegate.swift */; }; 11 | A11B95262268E2190049EFC8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A11B95252268E2190049EFC8 /* ViewController.swift */; }; 12 | A11B952B2268E21C0049EFC8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A11B952A2268E21C0049EFC8 /* Assets.xcassets */; }; 13 | A11B952E2268E21C0049EFC8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A11B952C2268E21C0049EFC8 /* LaunchScreen.storyboard */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXFileReference section */ 17 | A11B95202268E2190049EFC8 /* NGUIButtonInsetsExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NGUIButtonInsetsExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 18 | A11B95232268E2190049EFC8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 19 | A11B95252268E2190049EFC8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 20 | A11B952A2268E21C0049EFC8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 21 | A11B952D2268E21C0049EFC8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 22 | A11B952F2268E21C0049EFC8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 23 | /* End PBXFileReference section */ 24 | 25 | /* Begin PBXFrameworksBuildPhase section */ 26 | A11B951D2268E2190049EFC8 /* Frameworks */ = { 27 | isa = PBXFrameworksBuildPhase; 28 | buildActionMask = 2147483647; 29 | files = ( 30 | ); 31 | runOnlyForDeploymentPostprocessing = 0; 32 | }; 33 | /* End PBXFrameworksBuildPhase section */ 34 | 35 | /* Begin PBXGroup section */ 36 | A11B95172268E2190049EFC8 = { 37 | isa = PBXGroup; 38 | children = ( 39 | A11B95222268E2190049EFC8 /* NGUIButtonInsetsExample */, 40 | A11B95212268E2190049EFC8 /* Products */, 41 | ); 42 | sourceTree = ""; 43 | }; 44 | A11B95212268E2190049EFC8 /* Products */ = { 45 | isa = PBXGroup; 46 | children = ( 47 | A11B95202268E2190049EFC8 /* NGUIButtonInsetsExample.app */, 48 | ); 49 | name = Products; 50 | sourceTree = ""; 51 | }; 52 | A11B95222268E2190049EFC8 /* NGUIButtonInsetsExample */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | A11B95232268E2190049EFC8 /* AppDelegate.swift */, 56 | A11B95252268E2190049EFC8 /* ViewController.swift */, 57 | A11B952A2268E21C0049EFC8 /* Assets.xcassets */, 58 | A11B952C2268E21C0049EFC8 /* LaunchScreen.storyboard */, 59 | A11B952F2268E21C0049EFC8 /* Info.plist */, 60 | ); 61 | path = NGUIButtonInsetsExample; 62 | sourceTree = ""; 63 | }; 64 | /* End PBXGroup section */ 65 | 66 | /* Begin PBXNativeTarget section */ 67 | A11B951F2268E2190049EFC8 /* NGUIButtonInsetsExample */ = { 68 | isa = PBXNativeTarget; 69 | buildConfigurationList = A11B95322268E21C0049EFC8 /* Build configuration list for PBXNativeTarget "NGUIButtonInsetsExample" */; 70 | buildPhases = ( 71 | A11B951C2268E2190049EFC8 /* Sources */, 72 | A11B951D2268E2190049EFC8 /* Frameworks */, 73 | A11B951E2268E2190049EFC8 /* Resources */, 74 | ); 75 | buildRules = ( 76 | ); 77 | dependencies = ( 78 | ); 79 | name = NGUIButtonInsetsExample; 80 | productName = NGUIButtonInsetsExample; 81 | productReference = A11B95202268E2190049EFC8 /* NGUIButtonInsetsExample.app */; 82 | productType = "com.apple.product-type.application"; 83 | }; 84 | /* End PBXNativeTarget section */ 85 | 86 | /* Begin PBXProject section */ 87 | A11B95182268E2190049EFC8 /* Project object */ = { 88 | isa = PBXProject; 89 | attributes = { 90 | LastSwiftUpdateCheck = 1010; 91 | LastUpgradeCheck = 1010; 92 | ORGANIZATIONNAME = "Noah Gilmore"; 93 | TargetAttributes = { 94 | A11B951F2268E2190049EFC8 = { 95 | CreatedOnToolsVersion = 10.1; 96 | }; 97 | }; 98 | }; 99 | buildConfigurationList = A11B951B2268E2190049EFC8 /* Build configuration list for PBXProject "NGUIButtonInsetsExample" */; 100 | compatibilityVersion = "Xcode 9.3"; 101 | developmentRegion = en; 102 | hasScannedForEncodings = 0; 103 | knownRegions = ( 104 | en, 105 | Base, 106 | ); 107 | mainGroup = A11B95172268E2190049EFC8; 108 | productRefGroup = A11B95212268E2190049EFC8 /* Products */; 109 | projectDirPath = ""; 110 | projectRoot = ""; 111 | targets = ( 112 | A11B951F2268E2190049EFC8 /* NGUIButtonInsetsExample */, 113 | ); 114 | }; 115 | /* End PBXProject section */ 116 | 117 | /* Begin PBXResourcesBuildPhase section */ 118 | A11B951E2268E2190049EFC8 /* Resources */ = { 119 | isa = PBXResourcesBuildPhase; 120 | buildActionMask = 2147483647; 121 | files = ( 122 | A11B952E2268E21C0049EFC8 /* LaunchScreen.storyboard in Resources */, 123 | A11B952B2268E21C0049EFC8 /* Assets.xcassets in Resources */, 124 | ); 125 | runOnlyForDeploymentPostprocessing = 0; 126 | }; 127 | /* End PBXResourcesBuildPhase section */ 128 | 129 | /* Begin PBXSourcesBuildPhase section */ 130 | A11B951C2268E2190049EFC8 /* Sources */ = { 131 | isa = PBXSourcesBuildPhase; 132 | buildActionMask = 2147483647; 133 | files = ( 134 | A11B95262268E2190049EFC8 /* ViewController.swift in Sources */, 135 | A11B95242268E2190049EFC8 /* AppDelegate.swift in Sources */, 136 | ); 137 | runOnlyForDeploymentPostprocessing = 0; 138 | }; 139 | /* End PBXSourcesBuildPhase section */ 140 | 141 | /* Begin PBXVariantGroup section */ 142 | A11B952C2268E21C0049EFC8 /* LaunchScreen.storyboard */ = { 143 | isa = PBXVariantGroup; 144 | children = ( 145 | A11B952D2268E21C0049EFC8 /* Base */, 146 | ); 147 | name = LaunchScreen.storyboard; 148 | sourceTree = ""; 149 | }; 150 | /* End PBXVariantGroup section */ 151 | 152 | /* Begin XCBuildConfiguration section */ 153 | A11B95302268E21C0049EFC8 /* Debug */ = { 154 | isa = XCBuildConfiguration; 155 | buildSettings = { 156 | ALWAYS_SEARCH_USER_PATHS = NO; 157 | CLANG_ANALYZER_NONNULL = YES; 158 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 159 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 160 | CLANG_CXX_LIBRARY = "libc++"; 161 | CLANG_ENABLE_MODULES = YES; 162 | CLANG_ENABLE_OBJC_ARC = YES; 163 | CLANG_ENABLE_OBJC_WEAK = YES; 164 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 165 | CLANG_WARN_BOOL_CONVERSION = YES; 166 | CLANG_WARN_COMMA = YES; 167 | CLANG_WARN_CONSTANT_CONVERSION = YES; 168 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 169 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 170 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 171 | CLANG_WARN_EMPTY_BODY = YES; 172 | CLANG_WARN_ENUM_CONVERSION = YES; 173 | CLANG_WARN_INFINITE_RECURSION = YES; 174 | CLANG_WARN_INT_CONVERSION = YES; 175 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 176 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 177 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 178 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 179 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 180 | CLANG_WARN_STRICT_PROTOTYPES = YES; 181 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 182 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 183 | CLANG_WARN_UNREACHABLE_CODE = YES; 184 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 185 | CODE_SIGN_IDENTITY = "iPhone Developer"; 186 | COPY_PHASE_STRIP = NO; 187 | DEBUG_INFORMATION_FORMAT = dwarf; 188 | ENABLE_STRICT_OBJC_MSGSEND = YES; 189 | ENABLE_TESTABILITY = YES; 190 | GCC_C_LANGUAGE_STANDARD = gnu11; 191 | GCC_DYNAMIC_NO_PIC = NO; 192 | GCC_NO_COMMON_BLOCKS = YES; 193 | GCC_OPTIMIZATION_LEVEL = 0; 194 | GCC_PREPROCESSOR_DEFINITIONS = ( 195 | "DEBUG=1", 196 | "$(inherited)", 197 | ); 198 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 199 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 200 | GCC_WARN_UNDECLARED_SELECTOR = YES; 201 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 202 | GCC_WARN_UNUSED_FUNCTION = YES; 203 | GCC_WARN_UNUSED_VARIABLE = YES; 204 | IPHONEOS_DEPLOYMENT_TARGET = 12.1; 205 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 206 | MTL_FAST_MATH = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = iphoneos; 209 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 210 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 211 | }; 212 | name = Debug; 213 | }; 214 | A11B95312268E21C0049EFC8 /* Release */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | ALWAYS_SEARCH_USER_PATHS = NO; 218 | CLANG_ANALYZER_NONNULL = YES; 219 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 220 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 221 | CLANG_CXX_LIBRARY = "libc++"; 222 | CLANG_ENABLE_MODULES = YES; 223 | CLANG_ENABLE_OBJC_ARC = YES; 224 | CLANG_ENABLE_OBJC_WEAK = YES; 225 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 226 | CLANG_WARN_BOOL_CONVERSION = YES; 227 | CLANG_WARN_COMMA = YES; 228 | CLANG_WARN_CONSTANT_CONVERSION = YES; 229 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 230 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 231 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 232 | CLANG_WARN_EMPTY_BODY = YES; 233 | CLANG_WARN_ENUM_CONVERSION = YES; 234 | CLANG_WARN_INFINITE_RECURSION = YES; 235 | CLANG_WARN_INT_CONVERSION = YES; 236 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 237 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 238 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 239 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 240 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 241 | CLANG_WARN_STRICT_PROTOTYPES = YES; 242 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 243 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 244 | CLANG_WARN_UNREACHABLE_CODE = YES; 245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 246 | CODE_SIGN_IDENTITY = "iPhone Developer"; 247 | COPY_PHASE_STRIP = NO; 248 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 249 | ENABLE_NS_ASSERTIONS = NO; 250 | ENABLE_STRICT_OBJC_MSGSEND = YES; 251 | GCC_C_LANGUAGE_STANDARD = gnu11; 252 | GCC_NO_COMMON_BLOCKS = YES; 253 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 254 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 255 | GCC_WARN_UNDECLARED_SELECTOR = YES; 256 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 257 | GCC_WARN_UNUSED_FUNCTION = YES; 258 | GCC_WARN_UNUSED_VARIABLE = YES; 259 | IPHONEOS_DEPLOYMENT_TARGET = 12.1; 260 | MTL_ENABLE_DEBUG_INFO = NO; 261 | MTL_FAST_MATH = YES; 262 | SDKROOT = iphoneos; 263 | SWIFT_COMPILATION_MODE = wholemodule; 264 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 265 | VALIDATE_PRODUCT = YES; 266 | }; 267 | name = Release; 268 | }; 269 | A11B95332268E21C0049EFC8 /* Debug */ = { 270 | isa = XCBuildConfiguration; 271 | buildSettings = { 272 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 273 | CODE_SIGN_STYLE = Automatic; 274 | DEVELOPMENT_TEAM = XBE2EP7T4F; 275 | INFOPLIST_FILE = NGUIButtonInsetsExample/Info.plist; 276 | LD_RUNPATH_SEARCH_PATHS = ( 277 | "$(inherited)", 278 | "@executable_path/Frameworks", 279 | ); 280 | PRODUCT_BUNDLE_IDENTIFIER = com.noahgilmore.NGUIButtonInsetsExample; 281 | PRODUCT_NAME = "$(TARGET_NAME)"; 282 | SWIFT_VERSION = 4.2; 283 | TARGETED_DEVICE_FAMILY = "1,2"; 284 | }; 285 | name = Debug; 286 | }; 287 | A11B95342268E21C0049EFC8 /* Release */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 291 | CODE_SIGN_STYLE = Automatic; 292 | DEVELOPMENT_TEAM = XBE2EP7T4F; 293 | INFOPLIST_FILE = NGUIButtonInsetsExample/Info.plist; 294 | LD_RUNPATH_SEARCH_PATHS = ( 295 | "$(inherited)", 296 | "@executable_path/Frameworks", 297 | ); 298 | PRODUCT_BUNDLE_IDENTIFIER = com.noahgilmore.NGUIButtonInsetsExample; 299 | PRODUCT_NAME = "$(TARGET_NAME)"; 300 | SWIFT_VERSION = 4.2; 301 | TARGETED_DEVICE_FAMILY = "1,2"; 302 | }; 303 | name = Release; 304 | }; 305 | /* End XCBuildConfiguration section */ 306 | 307 | /* Begin XCConfigurationList section */ 308 | A11B951B2268E2190049EFC8 /* Build configuration list for PBXProject "NGUIButtonInsetsExample" */ = { 309 | isa = XCConfigurationList; 310 | buildConfigurations = ( 311 | A11B95302268E21C0049EFC8 /* Debug */, 312 | A11B95312268E21C0049EFC8 /* Release */, 313 | ); 314 | defaultConfigurationIsVisible = 0; 315 | defaultConfigurationName = Release; 316 | }; 317 | A11B95322268E21C0049EFC8 /* Build configuration list for PBXNativeTarget "NGUIButtonInsetsExample" */ = { 318 | isa = XCConfigurationList; 319 | buildConfigurations = ( 320 | A11B95332268E21C0049EFC8 /* Debug */, 321 | A11B95342268E21C0049EFC8 /* Release */, 322 | ); 323 | defaultConfigurationIsVisible = 0; 324 | defaultConfigurationName = Release; 325 | }; 326 | /* End XCConfigurationList section */ 327 | }; 328 | rootObject = A11B95182268E2190049EFC8 /* Project object */; 329 | } 330 | -------------------------------------------------------------------------------- /NGUIButtonInsetsExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NGUIButtonInsetsExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /NGUIButtonInsetsExample.xcodeproj/xcuserdata/noahgilmore.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NGUIButtonInsetsExample.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NGUIButtonInsetsExample 4 | // 5 | // Created by Noah Gilmore on 4/18/19. 6 | // Copyright © 2019 Noah Gilmore. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | 20 | window = UIWindow() 21 | window?.rootViewController = ViewController() 22 | window?.makeKeyAndVisible() 23 | 24 | return true 25 | } 26 | 27 | func applicationWillResignActive(_ application: UIApplication) { 28 | // 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. 29 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 30 | } 31 | 32 | func applicationDidEnterBackground(_ application: UIApplication) { 33 | // 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. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | func applicationWillEnterForeground(_ application: UIApplication) { 38 | // 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. 39 | } 40 | 41 | func applicationDidBecomeActive(_ application: UIApplication) { 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 | func applicationWillTerminate(_ application: UIApplication) { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/Artboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noahsark769/NGUIButtonInsetsExample/607b6819bd4911b6e71718a378625a08704965de/NGUIButtonInsetsExample/Artboard.png -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/Artboard@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noahsark769/NGUIButtonInsetsExample/607b6819bd4911b6e71718a378625a08704965de/NGUIButtonInsetsExample/Artboard@2x.png -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/Artboard@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noahsark769/NGUIButtonInsetsExample/607b6819bd4911b6e71718a378625a08704965de/NGUIButtonInsetsExample/Artboard@3x.png -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/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 | } -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/Assets.xcassets/image.imageset/Artboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noahsark769/NGUIButtonInsetsExample/607b6819bd4911b6e71718a378625a08704965de/NGUIButtonInsetsExample/Assets.xcassets/image.imageset/Artboard.png -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/Assets.xcassets/image.imageset/Artboard@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noahsark769/NGUIButtonInsetsExample/607b6819bd4911b6e71718a378625a08704965de/NGUIButtonInsetsExample/Assets.xcassets/image.imageset/Artboard@2x.png -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/Assets.xcassets/image.imageset/Artboard@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noahsark769/NGUIButtonInsetsExample/607b6819bd4911b6e71718a378625a08704965de/NGUIButtonInsetsExample/Assets.xcassets/image.imageset/Artboard@3x.png -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/Assets.xcassets/image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Artboard.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Artboard@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "Artboard@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/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 | -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/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 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | 33 | UISupportedInterfaceOrientations~ipad 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationPortraitUpsideDown 37 | UIInterfaceOrientationLandscapeLeft 38 | UIInterfaceOrientationLandscapeRight 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /NGUIButtonInsetsExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // NGUIButtonInsetsExample 4 | // 5 | // Created by Noah Gilmore on 4/18/19. 6 | // Copyright © 2019 Noah Gilmore. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | // MARK: - 12 | // MARK: Timer - 13 | 14 | final class TimerPool { 15 | static let shared = TimerPool() 16 | private var timers: [Timer] = [] 17 | 18 | func addTimer(_ block: @escaping () -> Void) { 19 | timers.append(Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true, block: { _ in 20 | block() 21 | })) 22 | } 23 | 24 | func invalidateAllTimers() { 25 | for timer in timers { 26 | timer.invalidate() 27 | } 28 | timers = [] 29 | } 30 | } 31 | 32 | // MARK: - 33 | // MARK: Types - 34 | 35 | enum InsetsType: String, CaseIterable { 36 | case image = "imageEdgeInsets" 37 | case content = "contentEdgeInsets" 38 | case title = "titleEdgeInsets" 39 | 40 | var displayName: String { 41 | return self.rawValue 42 | } 43 | } 44 | 45 | enum InsetsEdge: String { 46 | case top 47 | case left 48 | case bottom 49 | case right 50 | 51 | var displayName: String { 52 | return self.rawValue 53 | } 54 | } 55 | 56 | extension UIEdgeInsets { 57 | mutating func change(edge: InsetsEdge, to value: Int) { 58 | switch edge { 59 | case .top: self.top = CGFloat(value) 60 | case .bottom: self.bottom = CGFloat(value) 61 | case .left: self.left = CGFloat(value) 62 | case .right: self.right = CGFloat(value) 63 | } 64 | } 65 | } 66 | 67 | // MARK: - 68 | // MARK: Edge Sliders - 69 | 70 | final class EdgeSliderView: UIStackView { 71 | private let label = UILabel() 72 | private let valueLabel = UILabel() 73 | private let slider = UISlider() 74 | private let sliderDidChange: (Int) -> Void 75 | private var currentlyTickingPositively = true 76 | 77 | init(edge: InsetsEdge, sliderDidChange: @escaping (Int) -> Void) { 78 | self.sliderDidChange = sliderDidChange 79 | super.init(frame: .zero) 80 | self.axis = .horizontal 81 | self.spacing = 8 82 | 83 | label.text = edge.displayName 84 | label.font = .systemFont(ofSize: 12.0) 85 | label.adjustsFontSizeToFitWidth = true 86 | 87 | slider.minimumValue = -25 88 | slider.maximumValue = 25 89 | slider.addTarget(self, action: #selector(sliderDidChange(_:)), for: .valueChanged) 90 | slider.widthAnchor.constraint(equalToConstant: 80).isActive = true 91 | valueLabel.widthAnchor.constraint(equalToConstant: 30).isActive = true 92 | label.setContentHuggingPriority(.required, for: .horizontal) 93 | valueLabel.setContentHuggingPriority(.required, for: .horizontal) 94 | 95 | self.addArrangedSubview(label) 96 | self.addArrangedSubview(slider) 97 | self.addArrangedSubview(valueLabel) 98 | valueLabel.text = "0" 99 | 100 | let doubleTap = UITapGestureRecognizer(target: self, action: #selector(labelWasDoubleTapped(_:))) 101 | doubleTap.numberOfTapsRequired = 1 102 | label.isUserInteractionEnabled = true 103 | label.addGestureRecognizer(doubleTap) 104 | } 105 | 106 | required init(coder: NSCoder) { 107 | fatalError("init(coder:) has not been implemented") 108 | } 109 | 110 | // MARK: Actions - 111 | 112 | @objc private func sliderDidChange(_ sender: UISlider) { 113 | let value = Int(round(sender.value)) 114 | self.sliderDidChange(value) 115 | self.valueLabel.text = "\(value)" 116 | } 117 | 118 | @objc private func labelWasDoubleTapped(_ sender: UITapGestureRecognizer) { 119 | TimerPool.shared.addTimer { 120 | self.tick() 121 | } 122 | } 123 | 124 | func reset() { 125 | self.slider.setValue(0, animated: true) 126 | self.sliderDidChange(self.slider) 127 | } 128 | 129 | func tick() { 130 | let value = Int(round(slider.value)) 131 | if Float(value) == slider.maximumValue { 132 | currentlyTickingPositively = false 133 | } 134 | if Float(value) == slider.minimumValue { 135 | currentlyTickingPositively = true 136 | } 137 | 138 | let newValue = currentlyTickingPositively ? value + 1 : value - 1 139 | slider.setValue(Float(newValue), animated: true) 140 | self.sliderDidChange(self.slider) 141 | } 142 | } 143 | 144 | final class InsetsView: UIStackView { 145 | private let firstStackView = UIStackView() 146 | private let secondStackView = UIStackView() 147 | private let insetsDidChange: (UIEdgeInsets) -> Void 148 | private var currentInsets: UIEdgeInsets = .zero 149 | private let label = UILabel() 150 | 151 | init(insets: InsetsType, insetsDidChange: @escaping (UIEdgeInsets) -> Void) { 152 | self.insetsDidChange = insetsDidChange 153 | super.init(frame: .zero) 154 | self.axis = .vertical 155 | self.spacing = 8 156 | 157 | self.addArrangedSubview(label) 158 | label.text = insets.displayName 159 | 160 | self.addArrangedSubview(firstStackView) 161 | self.addArrangedSubview(secondStackView) 162 | 163 | for stackView in [firstStackView, secondStackView] { 164 | stackView.axis = .horizontal 165 | stackView.spacing = 10 166 | } 167 | 168 | for edge in [InsetsEdge.top, InsetsEdge.bottom] { 169 | let slider = EdgeSliderView(edge: edge, sliderDidChange: { [weak self] value in 170 | guard let `self` = self else { return } 171 | self.edgeInset(edge, didChangeTo: value) 172 | }) 173 | self.firstStackView.addArrangedSubview(slider) 174 | } 175 | for edge in [InsetsEdge.left, InsetsEdge.right] { 176 | let slider = EdgeSliderView(edge: edge, sliderDidChange: { [weak self] value in 177 | guard let `self` = self else { return } 178 | self.edgeInset(edge, didChangeTo: value) 179 | }) 180 | self.secondStackView.addArrangedSubview(slider) 181 | } 182 | } 183 | 184 | private func edgeInset(_ edge: InsetsEdge, didChangeTo value: Int) { 185 | currentInsets.change(edge: edge, to: value) 186 | self.insetsDidChange(currentInsets) 187 | } 188 | 189 | required init(coder: NSCoder) { 190 | fatalError("init(coder:) has not been implemented") 191 | } 192 | 193 | func reset() { 194 | for stackView in [self.firstStackView, self.secondStackView] { 195 | for view in stackView.arrangedSubviews { 196 | if let view = view as? EdgeSliderView { 197 | view.reset() 198 | } 199 | } 200 | } 201 | } 202 | 203 | func tick() { 204 | for stackView in [self.firstStackView, self.secondStackView] { 205 | for view in stackView.arrangedSubviews { 206 | if let view = view as? EdgeSliderView { 207 | view.tick() 208 | } 209 | } 210 | } 211 | } 212 | } 213 | 214 | final class AllInsetsView: UIStackView { 215 | init(insetsDidChange: @escaping (InsetsType, UIEdgeInsets) -> Void) { 216 | super.init(frame: .zero) 217 | self.axis = .vertical 218 | self.spacing = 30 219 | 220 | for type in InsetsType.allCases { 221 | self.addArrangedSubview(InsetsView(insets: type, insetsDidChange: { insets in 222 | insetsDidChange(type, insets) 223 | })) 224 | } 225 | } 226 | 227 | required init(coder aDecoder: NSCoder) { 228 | fatalError("init(coder:) has not been implemented") 229 | } 230 | 231 | func reset() { 232 | for view in self.arrangedSubviews { 233 | if let view = view as? InsetsView { 234 | view.reset() 235 | } 236 | } 237 | } 238 | 239 | func tick() { 240 | for view in self.arrangedSubviews { 241 | if let view = view as? InsetsView { 242 | view.tick() 243 | } 244 | } 245 | } 246 | } 247 | 248 | // MARK: - 249 | // MARK: Buttons - 250 | 251 | final class ButtonsView: UIView { 252 | private let imageButton = UIButton() 253 | private let textButton = UIButton() 254 | private let bothButton = UIButton() 255 | 256 | init() { 257 | super.init(frame: .zero) 258 | 259 | for button in [textButton, imageButton, bothButton] { 260 | button.backgroundColor = .red 261 | addSubview(button) 262 | button.translatesAutoresizingMaskIntoConstraints = false 263 | button.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true 264 | } 265 | 266 | textButton.topAnchor.constraint(equalTo: self.topAnchor, constant: 8).isActive = true 267 | bothButton.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true 268 | imageButton.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -8).isActive = true 269 | 270 | for button in [imageButton, bothButton] { 271 | button.setImage(UIImage(named: "image")!, for: .normal) 272 | } 273 | 274 | for button in [textButton, bothButton] { 275 | button.setTitle("Button", for: .normal) 276 | } 277 | } 278 | 279 | required init?(coder aDecoder: NSCoder) { 280 | fatalError("init(coder:) has not been implemented") 281 | } 282 | 283 | func set(insets: UIEdgeInsets, type: InsetsType) { 284 | for button in [imageButton, textButton, bothButton] { 285 | switch type { 286 | case .image: button.imageEdgeInsets = insets 287 | case .title: button.titleEdgeInsets = insets 288 | case .content: button.contentEdgeInsets = insets 289 | } 290 | } 291 | } 292 | } 293 | 294 | // MARK: - 295 | // MARK: VC - 296 | 297 | class ViewController: UIViewController { 298 | 299 | // MARK: UI Properties - 300 | 301 | private lazy var buttonsView: ButtonsView = { 302 | let bsv = ButtonsView() 303 | bsv.translatesAutoresizingMaskIntoConstraints = false 304 | return bsv 305 | }() 306 | 307 | private lazy var resetButton: UIButton = { 308 | let rsb = UIButton() 309 | rsb.translatesAutoresizingMaskIntoConstraints = false 310 | rsb.setTitle("Reset", for: .normal) 311 | rsb.setTitleColor(.blue, for: .normal) 312 | rsb.addTarget(self, action: #selector(resetTapped), for: .touchUpInside) 313 | return rsb 314 | }() 315 | 316 | private lazy var stackView: UIStackView = { 317 | let stv = UIStackView() 318 | stv.axis = .vertical 319 | stv.spacing = 50 320 | stv.translatesAutoresizingMaskIntoConstraints = false 321 | stv.backgroundColor = .lightGray 322 | return stv 323 | }() 324 | 325 | private lazy var allInsetsView: AllInsetsView = { 326 | let aiv = AllInsetsView(insetsDidChange: { [weak self] type, insets in 327 | guard let `self` = self else { return } 328 | self.buttonsView.set(insets: insets, type: type) 329 | }) 330 | aiv.translatesAutoresizingMaskIntoConstraints = false 331 | aiv.backgroundColor = .lightGray 332 | return aiv 333 | }() 334 | 335 | //MARK: Properties - 336 | 337 | private var timer: Timer? 338 | 339 | // MARK: Lifecycle - 340 | 341 | override func viewDidLoad() { 342 | super.viewDidLoad() 343 | setupView() 344 | } 345 | } 346 | 347 | // MARK: Setup - 348 | 349 | private extension ViewController { 350 | 351 | func setupView() { 352 | view.backgroundColor = .white 353 | setupStackView() 354 | setupButtonsView() 355 | setupAllInsetsView() 356 | setupResetButton() 357 | } 358 | 359 | func setupStackView() { 360 | view.addSubview(stackView) 361 | view.leadingAnchor.constraint(equalTo: stackView.leadingAnchor, constant: -30).isActive = true 362 | view.trailingAnchor.constraint(equalTo: stackView.trailingAnchor, constant: 30).isActive = true 363 | view.safeAreaLayoutGuide.topAnchor.constraint(equalTo: stackView.topAnchor).isActive = true 364 | view.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: stackView.bottomAnchor).isActive = true 365 | } 366 | 367 | func setupButtonsView() { 368 | stackView.addArrangedSubview(buttonsView) 369 | buttonsView.heightAnchor.constraint(equalTo: stackView.heightAnchor, multiplier: 0.3).isActive = true 370 | } 371 | 372 | func setupAllInsetsView() { 373 | stackView.addArrangedSubview(allInsetsView) 374 | } 375 | 376 | func setupResetButton() { 377 | stackView.addArrangedSubview(resetButton) 378 | resetButton.heightAnchor.constraint(equalToConstant: 50).isActive = true 379 | } 380 | } 381 | 382 | // MARK: Actions - 383 | 384 | private extension ViewController { 385 | @objc private func resetTapped() { 386 | for view in stackView.arrangedSubviews { 387 | if let view = view as? AllInsetsView { view.reset() } 388 | } 389 | self.timer?.invalidate() 390 | TimerPool.shared.invalidateAllTimers() 391 | } 392 | } 393 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NGUIButtonInsetsExample 2 | Example app which shows how UIButton insets work 3 | 4 | 5 | 6 | ## Usage 7 | Run the app and use the sliders to edit the button insets. Double tap a label ("top", "left", etc) to start animating the inset. Use the reset button to cancel all animations and reset everything to 0. --------------------------------------------------------------------------------