├── .gitignore ├── LICENSE ├── README.md ├── Shadow Maker Example.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── seitk.xcuserdatad │ └── xcschemes │ ├── Shadow Maker Example.xcscheme │ └── xcschememanagement.plist ├── Shadow Maker Example ├── Classes │ ├── UIView+Shadow.h │ └── UIView+Shadow.m ├── Default-568h@2x.png ├── Default.png ├── Default@2x.png ├── PYAppDelegate.h ├── PYAppDelegate.m ├── PYViewController.h ├── PYViewController.m ├── Shadow Maker Example-Info.plist ├── Shadow Maker Example-Prefix.pch ├── en.lproj │ ├── InfoPlist.strings │ └── PYViewController.xib └── main.m └── screenshot0.png /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.xcuserstate 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Philip Yu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | UIView-Shadow-Maker 2 | =================== 3 | 4 | An UIView category that allow user to easily make inset shadow, customize the radius, alpha, color and directions. 5 | Shadows are drawn with CAGradient and added into an UIView with tag, remove viewWithTag in subviews to clear the shadow. 6 | This project is an example, category file can be found in /Shadow Maker Example/Classes 7 | 8 | Function 9 | \- (void) makeInsetShadow; 10 | \- (void) makeInsetShadowWithRadius:(float)radius Alpha:(float)alpha; 11 | \- (void) makeInsetShadowWithRadius:(float)radius Color:(UIColor *)color Directions:(NSArray *)directions; 12 | 13 | Example 14 | UIView *sampleView1 = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 100)]; 15 | [sampleView1 makeInsetShadowWithRadius:3.0 Alpha:0.4]; 16 | [self.view addSubview:sampleView1]; 17 | 18 | UIView *sampleView2 = [[UIView alloc] initWithFrame:CGRectMake(150, 100, 100, 200)]; 19 | [sampleView2 makeInsetShadowWithRadius:3.0 Color:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.4] Directions:[NSArray arrayWithObjects:@"top", @"bottom", nil]]; 20 | [self.view addSubview:sampleView2]; 21 | 22 | Screenshot 23 | ![ScreenShot](https://github.com/Seitk/UIView-Shadow-Maker/blob/master/screenshot0.png?raw=true) 24 | 25 | Contribute 26 | I'd love to include your contributions. Feel free to improve it, send comments or suggestions. Please let me know if you have great idea on it. 27 | 28 | Contact Me 29 | You can add me on Facebook - http://www.facebook.com/seitkk 30 | -------------------------------------------------------------------------------- /Shadow Maker Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9BD30B561741E91C004A056D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9BD30B551741E91C004A056D /* UIKit.framework */; }; 11 | 9BD30B581741E91C004A056D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9BD30B571741E91C004A056D /* Foundation.framework */; }; 12 | 9BD30B5A1741E91C004A056D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9BD30B591741E91C004A056D /* CoreGraphics.framework */; }; 13 | 9BD30B601741E91C004A056D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9BD30B5E1741E91C004A056D /* InfoPlist.strings */; }; 14 | 9BD30B621741E91C004A056D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BD30B611741E91C004A056D /* main.m */; }; 15 | 9BD30B661741E91C004A056D /* PYAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BD30B651741E91C004A056D /* PYAppDelegate.m */; }; 16 | 9BD30B681741E91C004A056D /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 9BD30B671741E91C004A056D /* Default.png */; }; 17 | 9BD30B6A1741E91C004A056D /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9BD30B691741E91C004A056D /* Default@2x.png */; }; 18 | 9BD30B6C1741E91C004A056D /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9BD30B6B1741E91C004A056D /* Default-568h@2x.png */; }; 19 | 9BD30B6F1741E91C004A056D /* PYViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BD30B6E1741E91C004A056D /* PYViewController.m */; }; 20 | 9BD30B721741E91C004A056D /* PYViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9BD30B701741E91C004A056D /* PYViewController.xib */; }; 21 | 9BD30B7A1741E934004A056D /* UIView+Shadow.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BD30B791741E934004A056D /* UIView+Shadow.m */; }; 22 | 9BD30B7D1741EB10004A056D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9BD30B7B1741EB0A004A056D /* QuartzCore.framework */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXFileReference section */ 26 | 9BD30B521741E91C004A056D /* Shadow Maker Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Shadow Maker Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | 9BD30B551741E91C004A056D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 28 | 9BD30B571741E91C004A056D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 29 | 9BD30B591741E91C004A056D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 30 | 9BD30B5D1741E91C004A056D /* Shadow Maker Example-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Shadow Maker Example-Info.plist"; sourceTree = ""; }; 31 | 9BD30B5F1741E91C004A056D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 32 | 9BD30B611741E91C004A056D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 33 | 9BD30B631741E91C004A056D /* Shadow Maker Example-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Shadow Maker Example-Prefix.pch"; sourceTree = ""; }; 34 | 9BD30B641741E91C004A056D /* PYAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PYAppDelegate.h; sourceTree = ""; }; 35 | 9BD30B651741E91C004A056D /* PYAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PYAppDelegate.m; sourceTree = ""; }; 36 | 9BD30B671741E91C004A056D /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 37 | 9BD30B691741E91C004A056D /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 38 | 9BD30B6B1741E91C004A056D /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 39 | 9BD30B6D1741E91C004A056D /* PYViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PYViewController.h; sourceTree = ""; }; 40 | 9BD30B6E1741E91C004A056D /* PYViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PYViewController.m; sourceTree = ""; }; 41 | 9BD30B711741E91C004A056D /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/PYViewController.xib; sourceTree = ""; }; 42 | 9BD30B781741E934004A056D /* UIView+Shadow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIView+Shadow.h"; path = "Classes/UIView+Shadow.h"; sourceTree = ""; }; 43 | 9BD30B791741E934004A056D /* UIView+Shadow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIView+Shadow.m"; path = "Classes/UIView+Shadow.m"; sourceTree = ""; }; 44 | 9BD30B7B1741EB0A004A056D /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 9BD30B4F1741E91C004A056D /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | 9BD30B7D1741EB10004A056D /* QuartzCore.framework in Frameworks */, 53 | 9BD30B561741E91C004A056D /* UIKit.framework in Frameworks */, 54 | 9BD30B581741E91C004A056D /* Foundation.framework in Frameworks */, 55 | 9BD30B5A1741E91C004A056D /* CoreGraphics.framework in Frameworks */, 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | /* End PBXFrameworksBuildPhase section */ 60 | 61 | /* Begin PBXGroup section */ 62 | 9BD30B491741E91C004A056D = { 63 | isa = PBXGroup; 64 | children = ( 65 | 9BD30B5B1741E91C004A056D /* Shadow Maker Example */, 66 | 9BD30B541741E91C004A056D /* Frameworks */, 67 | 9BD30B531741E91C004A056D /* Products */, 68 | ); 69 | sourceTree = ""; 70 | }; 71 | 9BD30B531741E91C004A056D /* Products */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 9BD30B521741E91C004A056D /* Shadow Maker Example.app */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | 9BD30B541741E91C004A056D /* Frameworks */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 9BD30B7B1741EB0A004A056D /* QuartzCore.framework */, 83 | 9BD30B551741E91C004A056D /* UIKit.framework */, 84 | 9BD30B571741E91C004A056D /* Foundation.framework */, 85 | 9BD30B591741E91C004A056D /* CoreGraphics.framework */, 86 | ); 87 | name = Frameworks; 88 | sourceTree = ""; 89 | }; 90 | 9BD30B5B1741E91C004A056D /* Shadow Maker Example */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 9BD30B641741E91C004A056D /* PYAppDelegate.h */, 94 | 9BD30B651741E91C004A056D /* PYAppDelegate.m */, 95 | 9BD30B6D1741E91C004A056D /* PYViewController.h */, 96 | 9BD30B6E1741E91C004A056D /* PYViewController.m */, 97 | 9BD30B781741E934004A056D /* UIView+Shadow.h */, 98 | 9BD30B791741E934004A056D /* UIView+Shadow.m */, 99 | 9BD30B701741E91C004A056D /* PYViewController.xib */, 100 | 9BD30B5C1741E91C004A056D /* Supporting Files */, 101 | ); 102 | path = "Shadow Maker Example"; 103 | sourceTree = ""; 104 | }; 105 | 9BD30B5C1741E91C004A056D /* Supporting Files */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 9BD30B5D1741E91C004A056D /* Shadow Maker Example-Info.plist */, 109 | 9BD30B5E1741E91C004A056D /* InfoPlist.strings */, 110 | 9BD30B611741E91C004A056D /* main.m */, 111 | 9BD30B631741E91C004A056D /* Shadow Maker Example-Prefix.pch */, 112 | 9BD30B671741E91C004A056D /* Default.png */, 113 | 9BD30B691741E91C004A056D /* Default@2x.png */, 114 | 9BD30B6B1741E91C004A056D /* Default-568h@2x.png */, 115 | ); 116 | name = "Supporting Files"; 117 | sourceTree = ""; 118 | }; 119 | /* End PBXGroup section */ 120 | 121 | /* Begin PBXNativeTarget section */ 122 | 9BD30B511741E91C004A056D /* Shadow Maker Example */ = { 123 | isa = PBXNativeTarget; 124 | buildConfigurationList = 9BD30B751741E91C004A056D /* Build configuration list for PBXNativeTarget "Shadow Maker Example" */; 125 | buildPhases = ( 126 | 9BD30B4E1741E91C004A056D /* Sources */, 127 | 9BD30B4F1741E91C004A056D /* Frameworks */, 128 | 9BD30B501741E91C004A056D /* Resources */, 129 | ); 130 | buildRules = ( 131 | ); 132 | dependencies = ( 133 | ); 134 | name = "Shadow Maker Example"; 135 | productName = "Shadow Maker Example"; 136 | productReference = 9BD30B521741E91C004A056D /* Shadow Maker Example.app */; 137 | productType = "com.apple.product-type.application"; 138 | }; 139 | /* End PBXNativeTarget section */ 140 | 141 | /* Begin PBXProject section */ 142 | 9BD30B4A1741E91C004A056D /* Project object */ = { 143 | isa = PBXProject; 144 | attributes = { 145 | CLASSPREFIX = PY; 146 | LastUpgradeCheck = 0460; 147 | ORGANIZATIONNAME = "Philip Yu"; 148 | }; 149 | buildConfigurationList = 9BD30B4D1741E91C004A056D /* Build configuration list for PBXProject "Shadow Maker Example" */; 150 | compatibilityVersion = "Xcode 3.2"; 151 | developmentRegion = English; 152 | hasScannedForEncodings = 0; 153 | knownRegions = ( 154 | en, 155 | ); 156 | mainGroup = 9BD30B491741E91C004A056D; 157 | productRefGroup = 9BD30B531741E91C004A056D /* Products */; 158 | projectDirPath = ""; 159 | projectRoot = ""; 160 | targets = ( 161 | 9BD30B511741E91C004A056D /* Shadow Maker Example */, 162 | ); 163 | }; 164 | /* End PBXProject section */ 165 | 166 | /* Begin PBXResourcesBuildPhase section */ 167 | 9BD30B501741E91C004A056D /* Resources */ = { 168 | isa = PBXResourcesBuildPhase; 169 | buildActionMask = 2147483647; 170 | files = ( 171 | 9BD30B601741E91C004A056D /* InfoPlist.strings in Resources */, 172 | 9BD30B681741E91C004A056D /* Default.png in Resources */, 173 | 9BD30B6A1741E91C004A056D /* Default@2x.png in Resources */, 174 | 9BD30B6C1741E91C004A056D /* Default-568h@2x.png in Resources */, 175 | 9BD30B721741E91C004A056D /* PYViewController.xib in Resources */, 176 | ); 177 | runOnlyForDeploymentPostprocessing = 0; 178 | }; 179 | /* End PBXResourcesBuildPhase section */ 180 | 181 | /* Begin PBXSourcesBuildPhase section */ 182 | 9BD30B4E1741E91C004A056D /* Sources */ = { 183 | isa = PBXSourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | 9BD30B621741E91C004A056D /* main.m in Sources */, 187 | 9BD30B661741E91C004A056D /* PYAppDelegate.m in Sources */, 188 | 9BD30B6F1741E91C004A056D /* PYViewController.m in Sources */, 189 | 9BD30B7A1741E934004A056D /* UIView+Shadow.m in Sources */, 190 | ); 191 | runOnlyForDeploymentPostprocessing = 0; 192 | }; 193 | /* End PBXSourcesBuildPhase section */ 194 | 195 | /* Begin PBXVariantGroup section */ 196 | 9BD30B5E1741E91C004A056D /* InfoPlist.strings */ = { 197 | isa = PBXVariantGroup; 198 | children = ( 199 | 9BD30B5F1741E91C004A056D /* en */, 200 | ); 201 | name = InfoPlist.strings; 202 | sourceTree = ""; 203 | }; 204 | 9BD30B701741E91C004A056D /* PYViewController.xib */ = { 205 | isa = PBXVariantGroup; 206 | children = ( 207 | 9BD30B711741E91C004A056D /* en */, 208 | ); 209 | name = PYViewController.xib; 210 | sourceTree = ""; 211 | }; 212 | /* End PBXVariantGroup section */ 213 | 214 | /* Begin XCBuildConfiguration section */ 215 | 9BD30B731741E91C004A056D /* Debug */ = { 216 | isa = XCBuildConfiguration; 217 | buildSettings = { 218 | ALWAYS_SEARCH_USER_PATHS = NO; 219 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 220 | CLANG_CXX_LIBRARY = "libc++"; 221 | CLANG_ENABLE_OBJC_ARC = YES; 222 | CLANG_WARN_CONSTANT_CONVERSION = YES; 223 | CLANG_WARN_EMPTY_BODY = YES; 224 | CLANG_WARN_ENUM_CONVERSION = YES; 225 | CLANG_WARN_INT_CONVERSION = YES; 226 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 227 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 228 | COPY_PHASE_STRIP = NO; 229 | GCC_C_LANGUAGE_STANDARD = gnu99; 230 | GCC_DYNAMIC_NO_PIC = NO; 231 | GCC_OPTIMIZATION_LEVEL = 0; 232 | GCC_PREPROCESSOR_DEFINITIONS = ( 233 | "DEBUG=1", 234 | "$(inherited)", 235 | ); 236 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 237 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 238 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 239 | GCC_WARN_UNUSED_VARIABLE = YES; 240 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 241 | ONLY_ACTIVE_ARCH = YES; 242 | SDKROOT = iphoneos; 243 | }; 244 | name = Debug; 245 | }; 246 | 9BD30B741741E91C004A056D /* Release */ = { 247 | isa = XCBuildConfiguration; 248 | buildSettings = { 249 | ALWAYS_SEARCH_USER_PATHS = NO; 250 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 251 | CLANG_CXX_LIBRARY = "libc++"; 252 | CLANG_ENABLE_OBJC_ARC = YES; 253 | CLANG_WARN_CONSTANT_CONVERSION = YES; 254 | CLANG_WARN_EMPTY_BODY = YES; 255 | CLANG_WARN_ENUM_CONVERSION = YES; 256 | CLANG_WARN_INT_CONVERSION = YES; 257 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 258 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 259 | COPY_PHASE_STRIP = YES; 260 | GCC_C_LANGUAGE_STANDARD = gnu99; 261 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 262 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 263 | GCC_WARN_UNUSED_VARIABLE = YES; 264 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 265 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 266 | SDKROOT = iphoneos; 267 | VALIDATE_PRODUCT = YES; 268 | }; 269 | name = Release; 270 | }; 271 | 9BD30B761741E91C004A056D /* Debug */ = { 272 | isa = XCBuildConfiguration; 273 | buildSettings = { 274 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 275 | GCC_PREFIX_HEADER = "Shadow Maker Example/Shadow Maker Example-Prefix.pch"; 276 | INFOPLIST_FILE = "Shadow Maker Example/Shadow Maker Example-Info.plist"; 277 | PRODUCT_NAME = "$(TARGET_NAME)"; 278 | WRAPPER_EXTENSION = app; 279 | }; 280 | name = Debug; 281 | }; 282 | 9BD30B771741E91C004A056D /* Release */ = { 283 | isa = XCBuildConfiguration; 284 | buildSettings = { 285 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 286 | GCC_PREFIX_HEADER = "Shadow Maker Example/Shadow Maker Example-Prefix.pch"; 287 | INFOPLIST_FILE = "Shadow Maker Example/Shadow Maker Example-Info.plist"; 288 | PRODUCT_NAME = "$(TARGET_NAME)"; 289 | WRAPPER_EXTENSION = app; 290 | }; 291 | name = Release; 292 | }; 293 | /* End XCBuildConfiguration section */ 294 | 295 | /* Begin XCConfigurationList section */ 296 | 9BD30B4D1741E91C004A056D /* Build configuration list for PBXProject "Shadow Maker Example" */ = { 297 | isa = XCConfigurationList; 298 | buildConfigurations = ( 299 | 9BD30B731741E91C004A056D /* Debug */, 300 | 9BD30B741741E91C004A056D /* Release */, 301 | ); 302 | defaultConfigurationIsVisible = 0; 303 | defaultConfigurationName = Release; 304 | }; 305 | 9BD30B751741E91C004A056D /* Build configuration list for PBXNativeTarget "Shadow Maker Example" */ = { 306 | isa = XCConfigurationList; 307 | buildConfigurations = ( 308 | 9BD30B761741E91C004A056D /* Debug */, 309 | 9BD30B771741E91C004A056D /* Release */, 310 | ); 311 | defaultConfigurationIsVisible = 0; 312 | }; 313 | /* End XCConfigurationList section */ 314 | }; 315 | rootObject = 9BD30B4A1741E91C004A056D /* Project object */; 316 | } 317 | -------------------------------------------------------------------------------- /Shadow Maker Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Shadow Maker Example.xcodeproj/xcuserdata/seitk.xcuserdatad/xcschemes/Shadow Maker Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /Shadow Maker Example.xcodeproj/xcuserdata/seitk.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Shadow Maker Example.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 9BD30B511741E91C004A056D 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Shadow Maker Example/Classes/UIView+Shadow.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Shadow.h 3 | // Shadow Maker Example 4 | // 5 | // Created by Philip Yu on 5/14/13. 6 | // Copyright (c) 2013 Philip Yu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface UIView (Shadow) 13 | 14 | - (void) makeInsetShadow; 15 | - (void) makeInsetShadowWithRadius:(float)radius Alpha:(float)alpha; 16 | - (void) makeInsetShadowWithRadius:(float)radius Color:(UIColor *)color Directions:(NSArray *)directions; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Shadow Maker Example/Classes/UIView+Shadow.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Shadow.m 3 | // Shadow Maker Example 4 | // 5 | // Created by Philip Yu on 5/14/13. 6 | // Copyright (c) 2013 Philip Yu. All rights reserved. 7 | // 8 | 9 | #import "UIView+Shadow.h" 10 | 11 | #define kShadowViewTag 2132 12 | #define kValidDirections [NSArray arrayWithObjects: @"top", @"bottom", @"left", @"right",nil] 13 | 14 | @implementation UIView (Shadow) 15 | 16 | - (void) makeInsetShadow 17 | { 18 | NSArray *shadowDirections = [NSArray arrayWithObjects:@"top", @"bottom", @"left" , @"right" , nil]; 19 | UIColor *color = [UIColor colorWithRed:(0.0) green:(0.0) blue:(0.0) alpha:0.5]; 20 | 21 | UIView *shadowView = [self createShadowViewWithRadius:3 Color:color Directions:shadowDirections]; 22 | shadowView.tag = kShadowViewTag; 23 | 24 | [self addSubview:shadowView]; 25 | } 26 | 27 | - (void) makeInsetShadowWithRadius:(float)radius Alpha:(float)alpha 28 | { 29 | NSArray *shadowDirections = [NSArray arrayWithObjects:@"top", @"bottom", @"left" , @"right" , nil]; 30 | UIColor *color = [UIColor colorWithRed:(0.0) green:(0.0) blue:(0.0) alpha:alpha]; 31 | 32 | UIView *shadowView = [self createShadowViewWithRadius:radius Color:color Directions:shadowDirections]; 33 | shadowView.tag = kShadowViewTag; 34 | 35 | [self addSubview:shadowView]; 36 | } 37 | 38 | - (void) makeInsetShadowWithRadius:(float)radius Color:(UIColor *)color Directions:(NSArray *)directions 39 | { 40 | UIView *shadowView = [self createShadowViewWithRadius:radius Color:color Directions:directions]; 41 | shadowView.tag = kShadowViewTag; 42 | 43 | [self addSubview:shadowView]; 44 | } 45 | 46 | - (UIView *) createShadowViewWithRadius:(float)radius Color:(UIColor *)color Directions:(NSArray *)directions 47 | { 48 | UIView *shadowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)]; 49 | shadowView.backgroundColor = [UIColor clearColor]; 50 | 51 | // Ignore duplicate direction 52 | NSMutableDictionary *directionDict = [[NSMutableDictionary alloc] init]; 53 | for (NSString *direction in directions) [directionDict setObject:@"1" forKey:direction]; 54 | 55 | for (NSString *direction in directionDict) { 56 | // Ignore invalid direction 57 | if ([kValidDirections containsObject:direction]) 58 | { 59 | CAGradientLayer *shadow = [CAGradientLayer layer]; 60 | 61 | if ([direction isEqualToString:@"top"]) { 62 | [shadow setStartPoint:CGPointMake(0.5, 0.0)]; 63 | [shadow setEndPoint:CGPointMake(0.5, 1.0)]; 64 | shadow.frame = CGRectMake(0, 0, self.bounds.size.width, radius); 65 | } 66 | else if ([direction isEqualToString:@"bottom"]) 67 | { 68 | [shadow setStartPoint:CGPointMake(0.5, 1.0)]; 69 | [shadow setEndPoint:CGPointMake(0.5, 0.0)]; 70 | shadow.frame = CGRectMake(0, self.bounds.size.height - radius, self.bounds.size.width, radius); 71 | } else if ([direction isEqualToString:@"left"]) 72 | { 73 | shadow.frame = CGRectMake(0, 0, radius, self.bounds.size.height); 74 | [shadow setStartPoint:CGPointMake(0.0, 0.5)]; 75 | [shadow setEndPoint:CGPointMake(1.0, 0.5)]; 76 | } else if ([direction isEqualToString:@"right"]) 77 | { 78 | shadow.frame = CGRectMake(self.bounds.size.width - radius, 0, radius, self.bounds.size.height); 79 | [shadow setStartPoint:CGPointMake(1.0, 0.5)]; 80 | [shadow setEndPoint:CGPointMake(0.0, 0.5)]; 81 | } 82 | 83 | shadow.colors = [NSArray arrayWithObjects:(id)[color CGColor], (id)[[UIColor clearColor] CGColor], nil]; 84 | [shadowView.layer insertSublayer:shadow atIndex:0]; 85 | } 86 | } 87 | 88 | return shadowView; 89 | } 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /Shadow Maker Example/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seitk/UIView-Shadow-Maker/5e5074001a8d1b43f90358a56360039fe802884e/Shadow Maker Example/Default-568h@2x.png -------------------------------------------------------------------------------- /Shadow Maker Example/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seitk/UIView-Shadow-Maker/5e5074001a8d1b43f90358a56360039fe802884e/Shadow Maker Example/Default.png -------------------------------------------------------------------------------- /Shadow Maker Example/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seitk/UIView-Shadow-Maker/5e5074001a8d1b43f90358a56360039fe802884e/Shadow Maker Example/Default@2x.png -------------------------------------------------------------------------------- /Shadow Maker Example/PYAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // PYAppDelegate.h 3 | // Shadow Maker Example 4 | // 5 | // Created by Philip Yu on 5/14/13. 6 | // Copyright (c) 2013 Philip Yu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class PYViewController; 12 | 13 | @interface PYAppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | 17 | @property (strong, nonatomic) PYViewController *viewController; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Shadow Maker Example/PYAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // PYAppDelegate.m 3 | // Shadow Maker Example 4 | // 5 | // Created by Philip Yu on 5/14/13. 6 | // Copyright (c) 2013 Philip Yu. All rights reserved. 7 | // 8 | 9 | #import "PYAppDelegate.h" 10 | 11 | #import "PYViewController.h" 12 | 13 | @implementation PYAppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 18 | // Override point for customization after application launch. 19 | self.viewController = [[PYViewController alloc] initWithNibName:@"PYViewController" bundle:nil]; 20 | self.window.rootViewController = self.viewController; 21 | [self.window makeKeyAndVisible]; 22 | return YES; 23 | } 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application 26 | { 27 | // 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. 28 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 29 | } 30 | 31 | - (void)applicationDidEnterBackground:(UIApplication *)application 32 | { 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 | - (void)applicationWillEnterForeground:(UIApplication *)application 38 | { 39 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 40 | } 41 | 42 | - (void)applicationDidBecomeActive:(UIApplication *)application 43 | { 44 | // 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. 45 | } 46 | 47 | - (void)applicationWillTerminate:(UIApplication *)application 48 | { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Shadow Maker Example/PYViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PYViewController.h 3 | // Shadow Maker Example 4 | // 5 | // Created by Philip Yu on 5/14/13. 6 | // Copyright (c) 2013 Philip Yu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PYViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Shadow Maker Example/PYViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PYViewController.m 3 | // Shadow Maker Example 4 | // 5 | // Created by Philip Yu on 5/14/13. 6 | // Copyright (c) 2013 Philip Yu. All rights reserved. 7 | // 8 | 9 | #import "PYViewController.h" 10 | #import "UIView+Shadow.h" 11 | 12 | @interface PYViewController () 13 | 14 | @end 15 | 16 | @implementation PYViewController 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | 22 | UIView *sampleView1 = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 100)]; 23 | [sampleView1 makeInsetShadowWithRadius:3.0 Alpha:0.4]; 24 | [self.view addSubview:sampleView1]; 25 | 26 | UIView *sampleView2 = [[UIView alloc] initWithFrame:CGRectMake(150, 100, 100, 200)]; 27 | [sampleView2 makeInsetShadowWithRadius:3.0 Color:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.4] Directions:[NSArray arrayWithObjects:@"top", @"bottom", nil]]; 28 | [self.view addSubview:sampleView2]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Shadow Maker Example/Shadow Maker Example-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | PY.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Shadow Maker Example/Shadow Maker Example-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Shadow Maker Example' target in the 'Shadow Maker Example' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /Shadow Maker Example/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Shadow Maker Example/en.lproj/PYViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1552 5 | 12D78 6 | 3084 7 | 1187.37 8 | 626.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 2083 12 | 13 | 14 | IBProxyObject 15 | IBUIView 16 | 17 | 18 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 19 | 20 | 21 | PluginDependencyRecalculationVersion 22 | 23 | 24 | 25 | 26 | IBFilesOwner 27 | IBCocoaTouchFramework 28 | 29 | 30 | IBFirstResponder 31 | IBCocoaTouchFramework 32 | 33 | 34 | 35 | 274 36 | {{0, 20}, {320, 548}} 37 | 38 | 39 | 40 | 1 41 | MSAxIDEAA 42 | 43 | NO 44 | 45 | 46 | IBUIScreenMetrics 47 | 48 | YES 49 | 50 | 51 | 52 | 53 | 54 | {320, 568} 55 | {568, 320} 56 | 57 | 58 | IBCocoaTouchFramework 59 | Retina 4 Full Screen 60 | 2 61 | 62 | IBCocoaTouchFramework 63 | 64 | 65 | 66 | 67 | 68 | 69 | view 70 | 71 | 72 | 73 | 7 74 | 75 | 76 | 77 | 78 | 79 | 0 80 | 81 | 82 | 83 | 84 | 85 | -1 86 | 87 | 88 | File's Owner 89 | 90 | 91 | -2 92 | 93 | 94 | 95 | 96 | 6 97 | 98 | 99 | 100 | 101 | 102 | 103 | PYViewController 104 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 105 | UIResponder 106 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 107 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 108 | 109 | 110 | 111 | 112 | 113 | 7 114 | 115 | 116 | 117 | 118 | PYViewController 119 | UIViewController 120 | 121 | IBProjectSource 122 | ./Classes/PYViewController.h 123 | 124 | 125 | 126 | 127 | 0 128 | IBCocoaTouchFramework 129 | YES 130 | 3 131 | YES 132 | 2083 133 | 134 | 135 | -------------------------------------------------------------------------------- /Shadow Maker Example/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Shadow Maker Example 4 | // 5 | // Created by Philip Yu on 5/14/13. 6 | // Copyright (c) 2013 Philip Yu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "PYAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([PYAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /screenshot0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seitk/UIView-Shadow-Maker/5e5074001a8d1b43f90358a56360039fe802884e/screenshot0.png --------------------------------------------------------------------------------