├── README.md ├── darkMode.gif ├── lightMode.gif └── neumorphicButtons ├── neumorphicButtons.xcodeproj └── project.pbxproj └── neumorphicButtons ├── AppDelegate.swift ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Base.lproj └── LaunchScreen.storyboard ├── ContentView.swift ├── Extensions.swift ├── Info.plist ├── Preview Content └── Preview Assets.xcassets │ └── Contents.json └── SceneDelegate.swift /README.md: -------------------------------------------------------------------------------- 1 | # Soft Neumorphic Button styles using SwiftUI 2 | 3 | This project was written using SwiftUI in order to create an animation of a soft neumorphic styly button. This project was created by adapting some of the code from [Hacking with Swift] and the inspiration came from [Voicu Apostol]. 4 | 5 | 6 | The button can be made into either Light Mode or Dark mode by changing the colors from lightStart-> darkStart and lightEnd-> darkEnd. 7 | 8 | 9 | 10 | ![lightMode](/lightMode.gif) 11 | ![darkMode](/darkMode.gif) 12 | 13 | 14 | 15 | [Hacking with Swift]: 16 | [Voicu Apostol]: 17 | -------------------------------------------------------------------------------- /darkMode.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abruuham/Neumorphic-Buttons/45ec7fb8334c7caf7c882a27d66a444c4d0bbba6/darkMode.gif -------------------------------------------------------------------------------- /lightMode.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abruuham/Neumorphic-Buttons/45ec7fb8334c7caf7c882a27d66a444c4d0bbba6/lightMode.gif -------------------------------------------------------------------------------- /neumorphicButtons/neumorphicButtons.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 13F2C0802454490F00B71C2A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13F2C07F2454490F00B71C2A /* AppDelegate.swift */; }; 11 | 13F2C0822454490F00B71C2A /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13F2C0812454490F00B71C2A /* SceneDelegate.swift */; }; 12 | 13F2C0842454490F00B71C2A /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13F2C0832454490F00B71C2A /* ContentView.swift */; }; 13 | 13F2C0862454491500B71C2A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13F2C0852454491500B71C2A /* Assets.xcassets */; }; 14 | 13F2C0892454491500B71C2A /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13F2C0882454491500B71C2A /* Preview Assets.xcassets */; }; 15 | 13F2C08C2454491500B71C2A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 13F2C08A2454491500B71C2A /* LaunchScreen.storyboard */; }; 16 | 13F2C09424561E9C00B71C2A /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13F2C09324561E9B00B71C2A /* Extensions.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 13F2C07C2454490F00B71C2A /* neumorphicButtons.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = neumorphicButtons.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 13F2C07F2454490F00B71C2A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 13F2C0812454490F00B71C2A /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 23 | 13F2C0832454490F00B71C2A /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 24 | 13F2C0852454491500B71C2A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | 13F2C0882454491500B71C2A /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 26 | 13F2C08B2454491500B71C2A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 27 | 13F2C08D2454491500B71C2A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28 | 13F2C09324561E9B00B71C2A /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 13F2C0792454490F00B71C2A /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 13F2C0732454490F00B71C2A = { 43 | isa = PBXGroup; 44 | children = ( 45 | 13F2C07E2454490F00B71C2A /* neumorphicButtons */, 46 | 13F2C07D2454490F00B71C2A /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 13F2C07D2454490F00B71C2A /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 13F2C07C2454490F00B71C2A /* neumorphicButtons.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 13F2C07E2454490F00B71C2A /* neumorphicButtons */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 13F2C07F2454490F00B71C2A /* AppDelegate.swift */, 62 | 13F2C0812454490F00B71C2A /* SceneDelegate.swift */, 63 | 13F2C0832454490F00B71C2A /* ContentView.swift */, 64 | 13F2C0852454491500B71C2A /* Assets.xcassets */, 65 | 13F2C08A2454491500B71C2A /* LaunchScreen.storyboard */, 66 | 13F2C08D2454491500B71C2A /* Info.plist */, 67 | 13F2C0872454491500B71C2A /* Preview Content */, 68 | 13F2C09324561E9B00B71C2A /* Extensions.swift */, 69 | ); 70 | path = neumorphicButtons; 71 | sourceTree = ""; 72 | }; 73 | 13F2C0872454491500B71C2A /* Preview Content */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 13F2C0882454491500B71C2A /* Preview Assets.xcassets */, 77 | ); 78 | path = "Preview Content"; 79 | sourceTree = ""; 80 | }; 81 | /* End PBXGroup section */ 82 | 83 | /* Begin PBXNativeTarget section */ 84 | 13F2C07B2454490F00B71C2A /* neumorphicButtons */ = { 85 | isa = PBXNativeTarget; 86 | buildConfigurationList = 13F2C0902454491500B71C2A /* Build configuration list for PBXNativeTarget "neumorphicButtons" */; 87 | buildPhases = ( 88 | 13F2C0782454490F00B71C2A /* Sources */, 89 | 13F2C0792454490F00B71C2A /* Frameworks */, 90 | 13F2C07A2454490F00B71C2A /* Resources */, 91 | ); 92 | buildRules = ( 93 | ); 94 | dependencies = ( 95 | ); 96 | name = neumorphicButtons; 97 | productName = neumorphicButtons; 98 | productReference = 13F2C07C2454490F00B71C2A /* neumorphicButtons.app */; 99 | productType = "com.apple.product-type.application"; 100 | }; 101 | /* End PBXNativeTarget section */ 102 | 103 | /* Begin PBXProject section */ 104 | 13F2C0742454490F00B71C2A /* Project object */ = { 105 | isa = PBXProject; 106 | attributes = { 107 | LastSwiftUpdateCheck = 1120; 108 | LastUpgradeCheck = 1120; 109 | ORGANIZATIONNAME = AbrahamCalvillo; 110 | TargetAttributes = { 111 | 13F2C07B2454490F00B71C2A = { 112 | CreatedOnToolsVersion = 11.2.1; 113 | }; 114 | }; 115 | }; 116 | buildConfigurationList = 13F2C0772454490F00B71C2A /* Build configuration list for PBXProject "neumorphicButtons" */; 117 | compatibilityVersion = "Xcode 9.3"; 118 | developmentRegion = en; 119 | hasScannedForEncodings = 0; 120 | knownRegions = ( 121 | en, 122 | Base, 123 | ); 124 | mainGroup = 13F2C0732454490F00B71C2A; 125 | productRefGroup = 13F2C07D2454490F00B71C2A /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | 13F2C07B2454490F00B71C2A /* neumorphicButtons */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXResourcesBuildPhase section */ 135 | 13F2C07A2454490F00B71C2A /* Resources */ = { 136 | isa = PBXResourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 13F2C08C2454491500B71C2A /* LaunchScreen.storyboard in Resources */, 140 | 13F2C0892454491500B71C2A /* Preview Assets.xcassets in Resources */, 141 | 13F2C0862454491500B71C2A /* Assets.xcassets in Resources */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXResourcesBuildPhase section */ 146 | 147 | /* Begin PBXSourcesBuildPhase section */ 148 | 13F2C0782454490F00B71C2A /* Sources */ = { 149 | isa = PBXSourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | 13F2C0802454490F00B71C2A /* AppDelegate.swift in Sources */, 153 | 13F2C0822454490F00B71C2A /* SceneDelegate.swift in Sources */, 154 | 13F2C0842454490F00B71C2A /* ContentView.swift in Sources */, 155 | 13F2C09424561E9C00B71C2A /* Extensions.swift in Sources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXSourcesBuildPhase section */ 160 | 161 | /* Begin PBXVariantGroup section */ 162 | 13F2C08A2454491500B71C2A /* LaunchScreen.storyboard */ = { 163 | isa = PBXVariantGroup; 164 | children = ( 165 | 13F2C08B2454491500B71C2A /* Base */, 166 | ); 167 | name = LaunchScreen.storyboard; 168 | sourceTree = ""; 169 | }; 170 | /* End PBXVariantGroup section */ 171 | 172 | /* Begin XCBuildConfiguration section */ 173 | 13F2C08E2454491500B71C2A /* Debug */ = { 174 | isa = XCBuildConfiguration; 175 | buildSettings = { 176 | ALWAYS_SEARCH_USER_PATHS = NO; 177 | CLANG_ANALYZER_NONNULL = YES; 178 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 179 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 180 | CLANG_CXX_LIBRARY = "libc++"; 181 | CLANG_ENABLE_MODULES = YES; 182 | CLANG_ENABLE_OBJC_ARC = YES; 183 | CLANG_ENABLE_OBJC_WEAK = YES; 184 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 185 | CLANG_WARN_BOOL_CONVERSION = YES; 186 | CLANG_WARN_COMMA = YES; 187 | CLANG_WARN_CONSTANT_CONVERSION = YES; 188 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 189 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 190 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 191 | CLANG_WARN_EMPTY_BODY = YES; 192 | CLANG_WARN_ENUM_CONVERSION = YES; 193 | CLANG_WARN_INFINITE_RECURSION = YES; 194 | CLANG_WARN_INT_CONVERSION = YES; 195 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 196 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 197 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 198 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 199 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 200 | CLANG_WARN_STRICT_PROTOTYPES = YES; 201 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 202 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 203 | CLANG_WARN_UNREACHABLE_CODE = YES; 204 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 205 | COPY_PHASE_STRIP = NO; 206 | DEBUG_INFORMATION_FORMAT = dwarf; 207 | ENABLE_STRICT_OBJC_MSGSEND = YES; 208 | ENABLE_TESTABILITY = YES; 209 | GCC_C_LANGUAGE_STANDARD = gnu11; 210 | GCC_DYNAMIC_NO_PIC = NO; 211 | GCC_NO_COMMON_BLOCKS = YES; 212 | GCC_OPTIMIZATION_LEVEL = 0; 213 | GCC_PREPROCESSOR_DEFINITIONS = ( 214 | "DEBUG=1", 215 | "$(inherited)", 216 | ); 217 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 218 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 219 | GCC_WARN_UNDECLARED_SELECTOR = YES; 220 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 221 | GCC_WARN_UNUSED_FUNCTION = YES; 222 | GCC_WARN_UNUSED_VARIABLE = YES; 223 | IPHONEOS_DEPLOYMENT_TARGET = 13.2; 224 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 225 | MTL_FAST_MATH = YES; 226 | ONLY_ACTIVE_ARCH = YES; 227 | SDKROOT = iphoneos; 228 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 229 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 230 | }; 231 | name = Debug; 232 | }; 233 | 13F2C08F2454491500B71C2A /* Release */ = { 234 | isa = XCBuildConfiguration; 235 | buildSettings = { 236 | ALWAYS_SEARCH_USER_PATHS = NO; 237 | CLANG_ANALYZER_NONNULL = YES; 238 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_ENABLE_OBJC_WEAK = YES; 244 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 245 | CLANG_WARN_BOOL_CONVERSION = YES; 246 | CLANG_WARN_COMMA = YES; 247 | CLANG_WARN_CONSTANT_CONVERSION = YES; 248 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 249 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 250 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 251 | CLANG_WARN_EMPTY_BODY = YES; 252 | CLANG_WARN_ENUM_CONVERSION = YES; 253 | CLANG_WARN_INFINITE_RECURSION = YES; 254 | CLANG_WARN_INT_CONVERSION = YES; 255 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 257 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 258 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 259 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 260 | CLANG_WARN_STRICT_PROTOTYPES = YES; 261 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 262 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 263 | CLANG_WARN_UNREACHABLE_CODE = YES; 264 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 265 | COPY_PHASE_STRIP = NO; 266 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 267 | ENABLE_NS_ASSERTIONS = NO; 268 | ENABLE_STRICT_OBJC_MSGSEND = YES; 269 | GCC_C_LANGUAGE_STANDARD = gnu11; 270 | GCC_NO_COMMON_BLOCKS = YES; 271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 273 | GCC_WARN_UNDECLARED_SELECTOR = YES; 274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 | GCC_WARN_UNUSED_FUNCTION = YES; 276 | GCC_WARN_UNUSED_VARIABLE = YES; 277 | IPHONEOS_DEPLOYMENT_TARGET = 13.2; 278 | MTL_ENABLE_DEBUG_INFO = NO; 279 | MTL_FAST_MATH = YES; 280 | SDKROOT = iphoneos; 281 | SWIFT_COMPILATION_MODE = wholemodule; 282 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 283 | VALIDATE_PRODUCT = YES; 284 | }; 285 | name = Release; 286 | }; 287 | 13F2C0912454491500B71C2A /* Debug */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 291 | CODE_SIGN_STYLE = Automatic; 292 | DEVELOPMENT_ASSET_PATHS = "\"neumorphicButtons/Preview Content\""; 293 | DEVELOPMENT_TEAM = 4YS5KGPXS7; 294 | ENABLE_PREVIEWS = YES; 295 | INFOPLIST_FILE = neumorphicButtons/Info.plist; 296 | LD_RUNPATH_SEARCH_PATHS = ( 297 | "$(inherited)", 298 | "@executable_path/Frameworks", 299 | ); 300 | PRODUCT_BUNDLE_IDENTIFIER = com.abrahamcalvillo.neumorphicButtons; 301 | PRODUCT_NAME = "$(TARGET_NAME)"; 302 | SWIFT_VERSION = 5.0; 303 | TARGETED_DEVICE_FAMILY = "1,2"; 304 | }; 305 | name = Debug; 306 | }; 307 | 13F2C0922454491500B71C2A /* Release */ = { 308 | isa = XCBuildConfiguration; 309 | buildSettings = { 310 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 311 | CODE_SIGN_STYLE = Automatic; 312 | DEVELOPMENT_ASSET_PATHS = "\"neumorphicButtons/Preview Content\""; 313 | DEVELOPMENT_TEAM = 4YS5KGPXS7; 314 | ENABLE_PREVIEWS = YES; 315 | INFOPLIST_FILE = neumorphicButtons/Info.plist; 316 | LD_RUNPATH_SEARCH_PATHS = ( 317 | "$(inherited)", 318 | "@executable_path/Frameworks", 319 | ); 320 | PRODUCT_BUNDLE_IDENTIFIER = com.abrahamcalvillo.neumorphicButtons; 321 | PRODUCT_NAME = "$(TARGET_NAME)"; 322 | SWIFT_VERSION = 5.0; 323 | TARGETED_DEVICE_FAMILY = "1,2"; 324 | }; 325 | name = Release; 326 | }; 327 | /* End XCBuildConfiguration section */ 328 | 329 | /* Begin XCConfigurationList section */ 330 | 13F2C0772454490F00B71C2A /* Build configuration list for PBXProject "neumorphicButtons" */ = { 331 | isa = XCConfigurationList; 332 | buildConfigurations = ( 333 | 13F2C08E2454491500B71C2A /* Debug */, 334 | 13F2C08F2454491500B71C2A /* Release */, 335 | ); 336 | defaultConfigurationIsVisible = 0; 337 | defaultConfigurationName = Release; 338 | }; 339 | 13F2C0902454491500B71C2A /* Build configuration list for PBXNativeTarget "neumorphicButtons" */ = { 340 | isa = XCConfigurationList; 341 | buildConfigurations = ( 342 | 13F2C0912454491500B71C2A /* Debug */, 343 | 13F2C0922454491500B71C2A /* Release */, 344 | ); 345 | defaultConfigurationIsVisible = 0; 346 | defaultConfigurationName = Release; 347 | }; 348 | /* End XCConfigurationList section */ 349 | }; 350 | rootObject = 13F2C0742454490F00B71C2A /* Project object */; 351 | } 352 | -------------------------------------------------------------------------------- /neumorphicButtons/neumorphicButtons/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // neumorphicButtons 4 | // 5 | // Created by Abraham Calvillo on 4/25/20. 6 | // Copyright © 2020 AbrahamCalvillo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /neumorphicButtons/neumorphicButtons/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 | } -------------------------------------------------------------------------------- /neumorphicButtons/neumorphicButtons/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /neumorphicButtons/neumorphicButtons/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 | -------------------------------------------------------------------------------- /neumorphicButtons/neumorphicButtons/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // neumorphicButtons 4 | // 5 | // Created by Abraham Calvillo on 4/25/20. 6 | // Copyright © 2020 AbrahamCalvillo. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import CoreHaptics 11 | 12 | struct ContentView: View { 13 | 14 | 15 | 16 | @State private var isToggled = false 17 | var body: some View { 18 | 19 | ZStack{ 20 | LinearGradient(Color.darkStart, Color.darkEnd ) 21 | 22 | 23 | VStack(spacing: 20){ 24 | Toggle(isOn: $isToggled) { 25 | Image(systemName: "heart.fill") 26 | .foregroundColor(.gray) 27 | .opacity(0) 28 | } 29 | .toggleStyle(ButtonToggleStyle()) 30 | 31 | 32 | ZStack{ 33 | Circle() 34 | .fill(LinearGradient(Color.darkEnd, Color.darkStart)) 35 | .frame(width: 15, height: 15) 36 | .blur(radius: 2.0) 37 | 38 | Circle() 39 | .frame(width: 5, height: 5) 40 | .foregroundColor(isToggled ? Color.green : Color.gray.opacity(0.5)) 41 | .animation(Animation.easeIn(duration: 0.3)) 42 | 43 | 44 | } 45 | .frame(width: 15, height: 15) 46 | } 47 | } 48 | .edgesIgnoringSafeArea(.all) 49 | 50 | } 51 | } 52 | 53 | 54 | struct ButtonBackground: View { 55 | var isHighlighted: Bool 56 | var shape: S 57 | 58 | var body: some View { 59 | ZStack { 60 | if isHighlighted { 61 | shape 62 | .fill(LinearGradient(Color.darkEnd, Color.darkStart)) 63 | .shadow(color: Color.darkStart, radius: 10, x: -10, y: -10) 64 | .shadow(color: Color.darkEnd, radius: 10, x: 10, y: 10) 65 | .blur(radius: 4) 66 | Image(systemName: "heart.fill") 67 | .foregroundColor(.gray) 68 | .opacity(0.3) 69 | 70 | 71 | 72 | } else { 73 | shape 74 | .fill(LinearGradient(Color.darkStart, Color.darkEnd)) 75 | .shadow(color: Color.darkStart, radius: 10, x: -10, y: -10) 76 | .shadow(color: Color.darkEnd, radius: 10, x: 10, y: 10) 77 | .blur(radius: 3) 78 | Image(systemName: "heart.fill") 79 | .foregroundColor(.gray) 80 | 81 | } 82 | } 83 | } 84 | } 85 | 86 | 87 | struct ButtonToggleStyle: ToggleStyle { 88 | 89 | func makeBody(configuration: Self.Configuration) -> some View { 90 | 91 | Button(action: { 92 | configuration.isOn.toggle() 93 | let impactLight = UIImpactFeedbackGenerator(style: .light) 94 | impactLight.impactOccurred() 95 | }) { 96 | configuration.label 97 | .frame(width: 90, height: 90) 98 | .contentShape(RoundedRectangle(cornerRadius: 45)) 99 | } 100 | .background( 101 | ButtonBackground(isHighlighted: configuration.isOn, shape: RoundedRectangle(cornerRadius: 45)) 102 | ) 103 | .animation(Animation.easeOut.speed(2.5)) 104 | 105 | } 106 | } 107 | 108 | 109 | 110 | struct ContentView_Previews: PreviewProvider { 111 | static var previews: some View { 112 | ContentView() 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /neumorphicButtons/neumorphicButtons/Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Extensions.swift 3 | // neumorphicButtons 4 | // 5 | // Created by Abraham Calvillo on 4/26/20. 6 | // Copyright © 2020 AbrahamCalvillo. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | 12 | extension Color { 13 | static let darkStart = Color(red: 50 / 255, green: 60 / 255, blue: 65 / 255) 14 | static let darkEnd = Color(red: 25 / 255, green: 25 / 255, blue: 30 / 255) 15 | 16 | static let lightStart = Color(red: 240/255, green: 240/255, blue: 246/255) 17 | static let lightEnd = Color(red: 120/255, green: 120/255, blue: 123/255) 18 | 19 | } 20 | 21 | extension LinearGradient { 22 | init(_ colors: Color...) { 23 | self.init(gradient: Gradient(colors: colors), startPoint: .topLeading, endPoint: .bottomTrailing) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /neumorphicButtons/neumorphicButtons/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 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | 37 | 38 | 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationPortraitUpsideDown 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /neumorphicButtons/neumorphicButtons/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /neumorphicButtons/neumorphicButtons/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // neumorphicButtons 4 | // 5 | // Created by Abraham Calvillo on 4/25/20. 6 | // Copyright © 2020 AbrahamCalvillo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftUI 11 | 12 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 18 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 19 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 20 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 21 | 22 | // Create the SwiftUI view that provides the window contents. 23 | let contentView = ContentView() 24 | 25 | // Use a UIHostingController as window root view controller. 26 | if let windowScene = scene as? UIWindowScene { 27 | let window = UIWindow(windowScene: windowScene) 28 | window.rootViewController = UIHostingController(rootView: contentView) 29 | self.window = window 30 | window.makeKeyAndVisible() 31 | } 32 | } 33 | 34 | func sceneDidDisconnect(_ scene: UIScene) { 35 | // Called as the scene is being released by the system. 36 | // This occurs shortly after the scene enters the background, or when its session is discarded. 37 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 38 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 39 | } 40 | 41 | func sceneDidBecomeActive(_ scene: UIScene) { 42 | // Called when the scene has moved from an inactive state to an active state. 43 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 44 | } 45 | 46 | func sceneWillResignActive(_ scene: UIScene) { 47 | // Called when the scene will move from an active state to an inactive state. 48 | // This may occur due to temporary interruptions (ex. an incoming phone call). 49 | } 50 | 51 | func sceneWillEnterForeground(_ scene: UIScene) { 52 | // Called as the scene transitions from the background to the foreground. 53 | // Use this method to undo the changes made on entering the background. 54 | } 55 | 56 | func sceneDidEnterBackground(_ scene: UIScene) { 57 | // Called as the scene transitions from the foreground to the background. 58 | // Use this method to save data, release shared resources, and store enough scene-specific state information 59 | // to restore the scene back to its current state. 60 | } 61 | 62 | 63 | } 64 | 65 | --------------------------------------------------------------------------------