├── .gitignore ├── EffectViewDemo ├── EffectViewDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── EffectViewDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── LBBlurredImage │ ├── .DS_Store │ ├── UIImage+ImageEffects.h │ ├── UIImage+ImageEffects.m │ ├── UIImageView+LBBlurredImage.h │ └── UIImageView+LBBlurredImage.m │ ├── UIView+Extension.h │ ├── UIView+Extension.m │ ├── ViewController.h │ ├── ViewController.m │ ├── huba.jpeg │ ├── huoying4.jpg │ └── main.m ├── IMAGE ├── img_001.png ├── img_002.png └── img_003.png ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A2061B1F1C47D0650005BFF4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A2061B1E1C47D0650005BFF4 /* main.m */; }; 11 | A2061B221C47D0650005BFF4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A2061B211C47D0650005BFF4 /* AppDelegate.m */; }; 12 | A2061B251C47D0650005BFF4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A2061B241C47D0650005BFF4 /* ViewController.m */; }; 13 | A2061B281C47D0650005BFF4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A2061B261C47D0650005BFF4 /* Main.storyboard */; }; 14 | A2061B2A1C47D0650005BFF4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A2061B291C47D0650005BFF4 /* Assets.xcassets */; }; 15 | A2061B2D1C47D0650005BFF4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A2061B2B1C47D0650005BFF4 /* LaunchScreen.storyboard */; }; 16 | A2061B391C47D0880005BFF4 /* UIImage+ImageEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = A2061B361C47D0880005BFF4 /* UIImage+ImageEffects.m */; }; 17 | A2061B3A1C47D0880005BFF4 /* UIImageView+LBBlurredImage.m in Sources */ = {isa = PBXBuildFile; fileRef = A2061B381C47D0880005BFF4 /* UIImageView+LBBlurredImage.m */; }; 18 | A2061B3D1C47D14F0005BFF4 /* huba.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = A2061B3B1C47D14F0005BFF4 /* huba.jpeg */; }; 19 | A2061B3E1C47D14F0005BFF4 /* huoying4.jpg in Resources */ = {isa = PBXBuildFile; fileRef = A2061B3C1C47D14F0005BFF4 /* huoying4.jpg */; }; 20 | A279C9441DC364C800ACA846 /* UIView+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = A279C9431DC364C800ACA846 /* UIView+Extension.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | A2061B1A1C47D0650005BFF4 /* EffectViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = EffectViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | A2061B1E1C47D0650005BFF4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 26 | A2061B201C47D0650005BFF4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 27 | A2061B211C47D0650005BFF4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 28 | A2061B231C47D0650005BFF4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 29 | A2061B241C47D0650005BFF4 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 30 | A2061B271C47D0650005BFF4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 31 | A2061B291C47D0650005BFF4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 32 | A2061B2C1C47D0650005BFF4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 33 | A2061B2E1C47D0650005BFF4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | A2061B351C47D0880005BFF4 /* UIImage+ImageEffects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+ImageEffects.h"; sourceTree = ""; }; 35 | A2061B361C47D0880005BFF4 /* UIImage+ImageEffects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+ImageEffects.m"; sourceTree = ""; }; 36 | A2061B371C47D0880005BFF4 /* UIImageView+LBBlurredImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+LBBlurredImage.h"; sourceTree = ""; }; 37 | A2061B381C47D0880005BFF4 /* UIImageView+LBBlurredImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+LBBlurredImage.m"; sourceTree = ""; }; 38 | A2061B3B1C47D14F0005BFF4 /* huba.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = huba.jpeg; sourceTree = ""; }; 39 | A2061B3C1C47D14F0005BFF4 /* huoying4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = huoying4.jpg; sourceTree = ""; }; 40 | A279C9421DC364C800ACA846 /* UIView+Extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Extension.h"; sourceTree = ""; }; 41 | A279C9431DC364C800ACA846 /* UIView+Extension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Extension.m"; sourceTree = ""; }; 42 | /* End PBXFileReference section */ 43 | 44 | /* Begin PBXFrameworksBuildPhase section */ 45 | A2061B171C47D0650005BFF4 /* Frameworks */ = { 46 | isa = PBXFrameworksBuildPhase; 47 | buildActionMask = 2147483647; 48 | files = ( 49 | ); 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | /* End PBXFrameworksBuildPhase section */ 53 | 54 | /* Begin PBXGroup section */ 55 | A2061B111C47D0650005BFF4 = { 56 | isa = PBXGroup; 57 | children = ( 58 | A2061B1C1C47D0650005BFF4 /* EffectViewDemo */, 59 | A2061B1B1C47D0650005BFF4 /* Products */, 60 | ); 61 | sourceTree = ""; 62 | }; 63 | A2061B1B1C47D0650005BFF4 /* Products */ = { 64 | isa = PBXGroup; 65 | children = ( 66 | A2061B1A1C47D0650005BFF4 /* EffectViewDemo.app */, 67 | ); 68 | name = Products; 69 | sourceTree = ""; 70 | }; 71 | A2061B1C1C47D0650005BFF4 /* EffectViewDemo */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | A2061B341C47D0880005BFF4 /* LBBlurredImage */, 75 | A2061B201C47D0650005BFF4 /* AppDelegate.h */, 76 | A2061B211C47D0650005BFF4 /* AppDelegate.m */, 77 | A2061B231C47D0650005BFF4 /* ViewController.h */, 78 | A2061B241C47D0650005BFF4 /* ViewController.m */, 79 | A279C9421DC364C800ACA846 /* UIView+Extension.h */, 80 | A279C9431DC364C800ACA846 /* UIView+Extension.m */, 81 | A2061B261C47D0650005BFF4 /* Main.storyboard */, 82 | A2061B291C47D0650005BFF4 /* Assets.xcassets */, 83 | A2061B2B1C47D0650005BFF4 /* LaunchScreen.storyboard */, 84 | A2061B2E1C47D0650005BFF4 /* Info.plist */, 85 | A2061B1D1C47D0650005BFF4 /* Supporting Files */, 86 | ); 87 | path = EffectViewDemo; 88 | sourceTree = ""; 89 | }; 90 | A2061B1D1C47D0650005BFF4 /* Supporting Files */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | A2061B3B1C47D14F0005BFF4 /* huba.jpeg */, 94 | A2061B3C1C47D14F0005BFF4 /* huoying4.jpg */, 95 | A2061B1E1C47D0650005BFF4 /* main.m */, 96 | ); 97 | name = "Supporting Files"; 98 | sourceTree = ""; 99 | }; 100 | A2061B341C47D0880005BFF4 /* LBBlurredImage */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | A2061B351C47D0880005BFF4 /* UIImage+ImageEffects.h */, 104 | A2061B361C47D0880005BFF4 /* UIImage+ImageEffects.m */, 105 | A2061B371C47D0880005BFF4 /* UIImageView+LBBlurredImage.h */, 106 | A2061B381C47D0880005BFF4 /* UIImageView+LBBlurredImage.m */, 107 | ); 108 | path = LBBlurredImage; 109 | sourceTree = ""; 110 | }; 111 | /* End PBXGroup section */ 112 | 113 | /* Begin PBXNativeTarget section */ 114 | A2061B191C47D0650005BFF4 /* EffectViewDemo */ = { 115 | isa = PBXNativeTarget; 116 | buildConfigurationList = A2061B311C47D0650005BFF4 /* Build configuration list for PBXNativeTarget "EffectViewDemo" */; 117 | buildPhases = ( 118 | A2061B161C47D0650005BFF4 /* Sources */, 119 | A2061B171C47D0650005BFF4 /* Frameworks */, 120 | A2061B181C47D0650005BFF4 /* Resources */, 121 | ); 122 | buildRules = ( 123 | ); 124 | dependencies = ( 125 | ); 126 | name = EffectViewDemo; 127 | productName = EffectViewDemo; 128 | productReference = A2061B1A1C47D0650005BFF4 /* EffectViewDemo.app */; 129 | productType = "com.apple.product-type.application"; 130 | }; 131 | /* End PBXNativeTarget section */ 132 | 133 | /* Begin PBXProject section */ 134 | A2061B121C47D0650005BFF4 /* Project object */ = { 135 | isa = PBXProject; 136 | attributes = { 137 | LastUpgradeCheck = 0710; 138 | ORGANIZATIONNAME = Arvin; 139 | TargetAttributes = { 140 | A2061B191C47D0650005BFF4 = { 141 | CreatedOnToolsVersion = 7.1; 142 | }; 143 | }; 144 | }; 145 | buildConfigurationList = A2061B151C47D0650005BFF4 /* Build configuration list for PBXProject "EffectViewDemo" */; 146 | compatibilityVersion = "Xcode 3.2"; 147 | developmentRegion = English; 148 | hasScannedForEncodings = 0; 149 | knownRegions = ( 150 | en, 151 | Base, 152 | ); 153 | mainGroup = A2061B111C47D0650005BFF4; 154 | productRefGroup = A2061B1B1C47D0650005BFF4 /* Products */; 155 | projectDirPath = ""; 156 | projectRoot = ""; 157 | targets = ( 158 | A2061B191C47D0650005BFF4 /* EffectViewDemo */, 159 | ); 160 | }; 161 | /* End PBXProject section */ 162 | 163 | /* Begin PBXResourcesBuildPhase section */ 164 | A2061B181C47D0650005BFF4 /* Resources */ = { 165 | isa = PBXResourcesBuildPhase; 166 | buildActionMask = 2147483647; 167 | files = ( 168 | A2061B2D1C47D0650005BFF4 /* LaunchScreen.storyboard in Resources */, 169 | A2061B3D1C47D14F0005BFF4 /* huba.jpeg in Resources */, 170 | A2061B2A1C47D0650005BFF4 /* Assets.xcassets in Resources */, 171 | A2061B281C47D0650005BFF4 /* Main.storyboard in Resources */, 172 | A2061B3E1C47D14F0005BFF4 /* huoying4.jpg in Resources */, 173 | ); 174 | runOnlyForDeploymentPostprocessing = 0; 175 | }; 176 | /* End PBXResourcesBuildPhase section */ 177 | 178 | /* Begin PBXSourcesBuildPhase section */ 179 | A2061B161C47D0650005BFF4 /* Sources */ = { 180 | isa = PBXSourcesBuildPhase; 181 | buildActionMask = 2147483647; 182 | files = ( 183 | A279C9441DC364C800ACA846 /* UIView+Extension.m in Sources */, 184 | A2061B391C47D0880005BFF4 /* UIImage+ImageEffects.m in Sources */, 185 | A2061B251C47D0650005BFF4 /* ViewController.m in Sources */, 186 | A2061B3A1C47D0880005BFF4 /* UIImageView+LBBlurredImage.m in Sources */, 187 | A2061B221C47D0650005BFF4 /* AppDelegate.m in Sources */, 188 | A2061B1F1C47D0650005BFF4 /* main.m in Sources */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | /* End PBXSourcesBuildPhase section */ 193 | 194 | /* Begin PBXVariantGroup section */ 195 | A2061B261C47D0650005BFF4 /* Main.storyboard */ = { 196 | isa = PBXVariantGroup; 197 | children = ( 198 | A2061B271C47D0650005BFF4 /* Base */, 199 | ); 200 | name = Main.storyboard; 201 | sourceTree = ""; 202 | }; 203 | A2061B2B1C47D0650005BFF4 /* LaunchScreen.storyboard */ = { 204 | isa = PBXVariantGroup; 205 | children = ( 206 | A2061B2C1C47D0650005BFF4 /* Base */, 207 | ); 208 | name = LaunchScreen.storyboard; 209 | sourceTree = ""; 210 | }; 211 | /* End PBXVariantGroup section */ 212 | 213 | /* Begin XCBuildConfiguration section */ 214 | A2061B2F1C47D0650005BFF4 /* Debug */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | ALWAYS_SEARCH_USER_PATHS = NO; 218 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 219 | CLANG_CXX_LIBRARY = "libc++"; 220 | CLANG_ENABLE_MODULES = YES; 221 | CLANG_ENABLE_OBJC_ARC = YES; 222 | CLANG_WARN_BOOL_CONVERSION = YES; 223 | CLANG_WARN_CONSTANT_CONVERSION = YES; 224 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 225 | CLANG_WARN_EMPTY_BODY = YES; 226 | CLANG_WARN_ENUM_CONVERSION = YES; 227 | CLANG_WARN_INT_CONVERSION = YES; 228 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 229 | CLANG_WARN_UNREACHABLE_CODE = YES; 230 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 231 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 232 | COPY_PHASE_STRIP = NO; 233 | DEBUG_INFORMATION_FORMAT = dwarf; 234 | ENABLE_STRICT_OBJC_MSGSEND = YES; 235 | ENABLE_TESTABILITY = YES; 236 | GCC_C_LANGUAGE_STANDARD = gnu99; 237 | GCC_DYNAMIC_NO_PIC = NO; 238 | GCC_NO_COMMON_BLOCKS = YES; 239 | GCC_OPTIMIZATION_LEVEL = 0; 240 | GCC_PREPROCESSOR_DEFINITIONS = ( 241 | "DEBUG=1", 242 | "$(inherited)", 243 | ); 244 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 245 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 246 | GCC_WARN_UNDECLARED_SELECTOR = YES; 247 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 248 | GCC_WARN_UNUSED_FUNCTION = YES; 249 | GCC_WARN_UNUSED_VARIABLE = YES; 250 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 251 | MTL_ENABLE_DEBUG_INFO = YES; 252 | ONLY_ACTIVE_ARCH = YES; 253 | SDKROOT = iphoneos; 254 | }; 255 | name = Debug; 256 | }; 257 | A2061B301C47D0650005BFF4 /* Release */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ALWAYS_SEARCH_USER_PATHS = NO; 261 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 262 | CLANG_CXX_LIBRARY = "libc++"; 263 | CLANG_ENABLE_MODULES = YES; 264 | CLANG_ENABLE_OBJC_ARC = YES; 265 | CLANG_WARN_BOOL_CONVERSION = YES; 266 | CLANG_WARN_CONSTANT_CONVERSION = YES; 267 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 268 | CLANG_WARN_EMPTY_BODY = YES; 269 | CLANG_WARN_ENUM_CONVERSION = YES; 270 | CLANG_WARN_INT_CONVERSION = YES; 271 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 272 | CLANG_WARN_UNREACHABLE_CODE = YES; 273 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 274 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 275 | COPY_PHASE_STRIP = NO; 276 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 277 | ENABLE_NS_ASSERTIONS = NO; 278 | ENABLE_STRICT_OBJC_MSGSEND = YES; 279 | GCC_C_LANGUAGE_STANDARD = gnu99; 280 | GCC_NO_COMMON_BLOCKS = YES; 281 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 282 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 283 | GCC_WARN_UNDECLARED_SELECTOR = YES; 284 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 285 | GCC_WARN_UNUSED_FUNCTION = YES; 286 | GCC_WARN_UNUSED_VARIABLE = YES; 287 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 288 | MTL_ENABLE_DEBUG_INFO = NO; 289 | SDKROOT = iphoneos; 290 | VALIDATE_PRODUCT = YES; 291 | }; 292 | name = Release; 293 | }; 294 | A2061B321C47D0650005BFF4 /* Debug */ = { 295 | isa = XCBuildConfiguration; 296 | buildSettings = { 297 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 298 | INFOPLIST_FILE = EffectViewDemo/Info.plist; 299 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 300 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 301 | PRODUCT_BUNDLE_IDENTIFIER = cn.Arvin.EffectViewDemo; 302 | PRODUCT_NAME = "$(TARGET_NAME)"; 303 | }; 304 | name = Debug; 305 | }; 306 | A2061B331C47D0650005BFF4 /* Release */ = { 307 | isa = XCBuildConfiguration; 308 | buildSettings = { 309 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 310 | INFOPLIST_FILE = EffectViewDemo/Info.plist; 311 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 312 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 313 | PRODUCT_BUNDLE_IDENTIFIER = cn.Arvin.EffectViewDemo; 314 | PRODUCT_NAME = "$(TARGET_NAME)"; 315 | }; 316 | name = Release; 317 | }; 318 | /* End XCBuildConfiguration section */ 319 | 320 | /* Begin XCConfigurationList section */ 321 | A2061B151C47D0650005BFF4 /* Build configuration list for PBXProject "EffectViewDemo" */ = { 322 | isa = XCConfigurationList; 323 | buildConfigurations = ( 324 | A2061B2F1C47D0650005BFF4 /* Debug */, 325 | A2061B301C47D0650005BFF4 /* Release */, 326 | ); 327 | defaultConfigurationIsVisible = 0; 328 | defaultConfigurationName = Release; 329 | }; 330 | A2061B311C47D0650005BFF4 /* Build configuration list for PBXNativeTarget "EffectViewDemo" */ = { 331 | isa = XCConfigurationList; 332 | buildConfigurations = ( 333 | A2061B321C47D0650005BFF4 /* Debug */, 334 | A2061B331C47D0650005BFF4 /* Release */, 335 | ); 336 | defaultConfigurationIsVisible = 0; 337 | defaultConfigurationName = Release; 338 | }; 339 | /* End XCConfigurationList section */ 340 | }; 341 | rootObject = A2061B121C47D0650005BFF4 /* Project object */; 342 | } 343 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // EffectViewDemo 4 | // 5 | // Created by Arvin on 16/1/14. 6 | // Copyright © 2016年 Arvin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // EffectViewDemo 4 | // 5 | // Created by Arvin on 16/1/14. 6 | // Copyright © 2016年 Arvin. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/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 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/LBBlurredImage/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kejiasir/EffectViewDemo/dcb60d2b55723d10c2bea9813d6c65ccebb7a204/EffectViewDemo/EffectViewDemo/LBBlurredImage/.DS_Store -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/LBBlurredImage/UIImage+ImageEffects.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: UIImage+ImageEffects.h 3 | Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur. 4 | Version: 1.0 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2013 Apple Inc. All Rights Reserved. 45 | 46 | 47 | Copyright © 2013 Apple Inc. All rights reserved. 48 | WWDC 2013 License 49 | 50 | NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013 51 | Session. Please refer to the applicable WWDC 2013 Session for further 52 | information. 53 | 54 | IMPORTANT: This Apple software is supplied to you by Apple Inc. 55 | ("Apple") in consideration of your agreement to the following terms, and 56 | your use, installation, modification or redistribution of this Apple 57 | software constitutes acceptance of these terms. If you do not agree with 58 | these terms, please do not use, install, modify or redistribute this 59 | Apple software. 60 | 61 | In consideration of your agreement to abide by the following terms, and 62 | subject to these terms, Apple grants you a non-exclusive license, under 63 | Apple's copyrights in this original Apple software (the "Apple 64 | Software"), to use, reproduce, modify and redistribute the Apple 65 | Software, with or without modifications, in source and/or binary forms; 66 | provided that if you redistribute the Apple Software in its entirety and 67 | without modifications, you must retain this notice and the following 68 | text and disclaimers in all such redistributions of the Apple Software. 69 | Neither the name, trademarks, service marks or logos of Apple Inc. may 70 | be used to endorse or promote products derived from the Apple Software 71 | without specific prior written permission from Apple. Except as 72 | expressly stated in this notice, no other rights or licenses, express or 73 | implied, are granted by Apple herein, including but not limited to any 74 | patent rights that may be infringed by your derivative works or by other 75 | works in which the Apple Software may be incorporated. 76 | 77 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES 78 | NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE 79 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR 80 | A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 81 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 82 | 83 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 84 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 85 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 86 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 87 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 88 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 89 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 90 | POSSIBILITY OF SUCH DAMAGE. 91 | 92 | EA1002 93 | 5/3/2013 94 | */ 95 | 96 | #import 97 | 98 | @interface UIImage (ImageEffects) 99 | 100 | - (UIImage *)applyLightEffect; 101 | - (UIImage *)applyExtraLightEffect; 102 | - (UIImage *)applyDarkEffect; 103 | - (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor; 104 | 105 | - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage; 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/LBBlurredImage/UIImage+ImageEffects.m: -------------------------------------------------------------------------------- 1 | /* 2 | File: UIImage+ImageEffects.m 3 | Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur. 4 | Version: 1.0 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2013 Apple Inc. All Rights Reserved. 45 | 46 | 47 | Copyright © 2013 Apple Inc. All rights reserved. 48 | WWDC 2013 License 49 | 50 | NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013 51 | Session. Please refer to the applicable WWDC 2013 Session for further 52 | information. 53 | 54 | IMPORTANT: This Apple software is supplied to you by Apple Inc. 55 | ("Apple") in consideration of your agreement to the following terms, and 56 | your use, installation, modification or redistribution of this Apple 57 | software constitutes acceptance of these terms. If you do not agree with 58 | these terms, please do not use, install, modify or redistribute this 59 | Apple software. 60 | 61 | In consideration of your agreement to abide by the following terms, and 62 | subject to these terms, Apple grants you a non-exclusive license, under 63 | Apple's copyrights in this original Apple software (the "Apple 64 | Software"), to use, reproduce, modify and redistribute the Apple 65 | Software, with or without modifications, in source and/or binary forms; 66 | provided that if you redistribute the Apple Software in its entirety and 67 | without modifications, you must retain this notice and the following 68 | text and disclaimers in all such redistributions of the Apple Software. 69 | Neither the name, trademarks, service marks or logos of Apple Inc. may 70 | be used to endorse or promote products derived from the Apple Software 71 | without specific prior written permission from Apple. Except as 72 | expressly stated in this notice, no other rights or licenses, express or 73 | implied, are granted by Apple herein, including but not limited to any 74 | patent rights that may be infringed by your derivative works or by other 75 | works in which the Apple Software may be incorporated. 76 | 77 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES 78 | NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE 79 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR 80 | A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 81 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 82 | 83 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 84 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 85 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 86 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 87 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 88 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 89 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 90 | POSSIBILITY OF SUCH DAMAGE. 91 | 92 | EA1002 93 | 5/3/2013 94 | */ 95 | 96 | #import "UIImage+ImageEffects.h" 97 | 98 | #import 99 | #import 100 | 101 | 102 | @implementation UIImage (ImageEffects) 103 | 104 | 105 | - (UIImage *)applyLightEffect 106 | { 107 | UIColor *tintColor = [UIColor colorWithWhite:1.0 alpha:0.3]; 108 | return [self applyBlurWithRadius:30 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil]; 109 | } 110 | 111 | 112 | - (UIImage *)applyExtraLightEffect 113 | { 114 | UIColor *tintColor = [UIColor colorWithWhite:0.97 alpha:0.82]; 115 | return [self applyBlurWithRadius:20 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil]; 116 | } 117 | 118 | 119 | - (UIImage *)applyDarkEffect 120 | { 121 | UIColor *tintColor = [UIColor colorWithWhite:0.11 alpha:0.73]; 122 | return [self applyBlurWithRadius:20 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil]; 123 | } 124 | 125 | 126 | - (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor 127 | { 128 | const CGFloat EffectColorAlpha = 0.6; 129 | UIColor *effectColor = tintColor; 130 | int componentCount = CGColorGetNumberOfComponents(tintColor.CGColor); 131 | if (componentCount == 2) { 132 | CGFloat b; 133 | if ([tintColor getWhite:&b alpha:NULL]) { 134 | effectColor = [UIColor colorWithWhite:b alpha:EffectColorAlpha]; 135 | } 136 | } 137 | else { 138 | CGFloat r, g, b; 139 | if ([tintColor getRed:&r green:&g blue:&b alpha:NULL]) { 140 | effectColor = [UIColor colorWithRed:r green:g blue:b alpha:EffectColorAlpha]; 141 | } 142 | } 143 | return [self applyBlurWithRadius:10 tintColor:effectColor saturationDeltaFactor:-1.0 maskImage:nil]; 144 | } 145 | 146 | 147 | - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage 148 | { 149 | // Check pre-conditions. 150 | if (self.size.width < 1 || self.size.height < 1) { 151 | NSLog (@"*** error: invalid size: (%.2f x %.2f). Both dimensions must be >= 1: %@", self.size.width, self.size.height, self); 152 | return nil; 153 | } 154 | if (!self.CGImage) { 155 | NSLog (@"*** error: image must be backed by a CGImage: %@", self); 156 | return nil; 157 | } 158 | if (maskImage && !maskImage.CGImage) { 159 | NSLog (@"*** error: maskImage must be backed by a CGImage: %@", maskImage); 160 | return nil; 161 | } 162 | 163 | CGRect imageRect = { CGPointZero, self.size }; 164 | UIImage *effectImage = self; 165 | 166 | BOOL hasBlur = blurRadius > __FLT_EPSILON__; 167 | BOOL hasSaturationChange = fabs(saturationDeltaFactor - 1.) > __FLT_EPSILON__; 168 | if (hasBlur || hasSaturationChange) { 169 | UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); 170 | CGContextRef effectInContext = UIGraphicsGetCurrentContext(); 171 | CGContextScaleCTM(effectInContext, 1.0, -1.0); 172 | CGContextTranslateCTM(effectInContext, 0, -self.size.height); 173 | CGContextDrawImage(effectInContext, imageRect, self.CGImage); 174 | 175 | vImage_Buffer effectInBuffer; 176 | effectInBuffer.data = CGBitmapContextGetData(effectInContext); 177 | effectInBuffer.width = CGBitmapContextGetWidth(effectInContext); 178 | effectInBuffer.height = CGBitmapContextGetHeight(effectInContext); 179 | effectInBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectInContext); 180 | 181 | UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); 182 | CGContextRef effectOutContext = UIGraphicsGetCurrentContext(); 183 | vImage_Buffer effectOutBuffer; 184 | effectOutBuffer.data = CGBitmapContextGetData(effectOutContext); 185 | effectOutBuffer.width = CGBitmapContextGetWidth(effectOutContext); 186 | effectOutBuffer.height = CGBitmapContextGetHeight(effectOutContext); 187 | effectOutBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectOutContext); 188 | 189 | if (hasBlur) { 190 | // A description of how to compute the box kernel width from the Gaussian 191 | // radius (aka standard deviation) appears in the SVG spec: 192 | // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement 193 | // 194 | // For larger values of 's' (s >= 2.0), an approximation can be used: Three 195 | // successive box-blurs build a piece-wise quadratic convolution kernel, which 196 | // approximates the Gaussian kernel to within roughly 3%. 197 | // 198 | // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5) 199 | // 200 | // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel. 201 | // 202 | CGFloat inputRadius = blurRadius * [[UIScreen mainScreen] scale]; 203 | NSUInteger radius = floor(inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5); 204 | if (radius % 2 != 1) { 205 | radius += 1; // force radius to be odd so that the three box-blur methodology works. 206 | } 207 | vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend); 208 | vImageBoxConvolve_ARGB8888(&effectOutBuffer, &effectInBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend); 209 | vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend); 210 | } 211 | BOOL effectImageBuffersAreSwapped = NO; 212 | if (hasSaturationChange) { 213 | CGFloat s = saturationDeltaFactor; 214 | CGFloat floatingPointSaturationMatrix[] = { 215 | 0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0, 216 | 0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0, 217 | 0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0, 218 | 0, 0, 0, 1, 219 | }; 220 | const int32_t divisor = 256; 221 | NSUInteger matrixSize = sizeof(floatingPointSaturationMatrix)/sizeof(floatingPointSaturationMatrix[0]); 222 | int16_t saturationMatrix[matrixSize]; 223 | for (NSUInteger i = 0; i < matrixSize; ++i) { 224 | saturationMatrix[i] = (int16_t)roundf(floatingPointSaturationMatrix[i] * divisor); 225 | } 226 | if (hasBlur) { 227 | vImageMatrixMultiply_ARGB8888(&effectOutBuffer, &effectInBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags); 228 | effectImageBuffersAreSwapped = YES; 229 | } 230 | else { 231 | vImageMatrixMultiply_ARGB8888(&effectInBuffer, &effectOutBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags); 232 | } 233 | } 234 | if (!effectImageBuffersAreSwapped) 235 | effectImage = UIGraphicsGetImageFromCurrentImageContext(); 236 | UIGraphicsEndImageContext(); 237 | 238 | if (effectImageBuffersAreSwapped) 239 | effectImage = UIGraphicsGetImageFromCurrentImageContext(); 240 | UIGraphicsEndImageContext(); 241 | } 242 | 243 | // Set up output context. 244 | UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); 245 | CGContextRef outputContext = UIGraphicsGetCurrentContext(); 246 | CGContextScaleCTM(outputContext, 1.0, -1.0); 247 | CGContextTranslateCTM(outputContext, 0, -self.size.height); 248 | 249 | // Draw base image. 250 | CGContextDrawImage(outputContext, imageRect, self.CGImage); 251 | 252 | // Draw effect image. 253 | if (hasBlur) { 254 | CGContextSaveGState(outputContext); 255 | if (maskImage) { 256 | CGContextClipToMask(outputContext, imageRect, maskImage.CGImage); 257 | } 258 | CGContextDrawImage(outputContext, imageRect, effectImage.CGImage); 259 | CGContextRestoreGState(outputContext); 260 | } 261 | 262 | // Add in color tint. 263 | if (tintColor) { 264 | CGContextSaveGState(outputContext); 265 | CGContextSetFillColorWithColor(outputContext, tintColor.CGColor); 266 | CGContextFillRect(outputContext, imageRect); 267 | CGContextRestoreGState(outputContext); 268 | } 269 | 270 | // Output image is ready. 271 | UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext(); 272 | UIGraphicsEndImageContext(); 273 | 274 | return outputImage; 275 | } 276 | 277 | 278 | @end 279 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/LBBlurredImage/UIImageView+LBBlurredImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+LBBlurredImage.h 3 | // LBBlurredImage 4 | // 5 | // Created by Luca Bernardi on 11/11/12. 6 | // Copyright (c) 2012 Luca Bernardi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void(^LBBlurredImageCompletionBlock)(void); 12 | 13 | extern CGFloat const kLBBlurredImageDefaultBlurRadius; 14 | 15 | @interface UIImageView (LBBlurredImage) 16 | 17 | /** 18 | Set the blurred version of the provided image to the UIImageView 19 | 20 | @param UIImage the image to blur and set as UIImageView's image 21 | @param CGFLoat the radius of the blur used by the Gaussian filter 22 | @param LBBlurredImageCompletionBlock a completion block called after the image 23 | was blurred and set to the UIImageView (the block is dispatched on main thread) 24 | */ 25 | - (void)setImageToBlur:(UIImage *)image 26 | blurRadius:(CGFloat)blurRadius 27 | completionBlock:(LBBlurredImageCompletionBlock)completion; 28 | 29 | /** 30 | Set the blurred version of the provided image to the UIImageView 31 | with the default blur radius 32 | 33 | @param UIImage the image to blur and set as UIImageView's image 34 | @param LBBlurredImageCompletionBlock a completion block called after the image 35 | was blurred and set to the UIImageView (the block is dispatched on main thread) 36 | */ 37 | - (void)setImageToBlur:(UIImage *)image 38 | completionBlock:(LBBlurredImageCompletionBlock)completion; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/LBBlurredImage/UIImageView+LBBlurredImage.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+LBBlurredImage.m 3 | // LBBlurredImage 4 | // 5 | // Created by Luca Bernardi on 11/11/12. 6 | // Copyright (c) 2012 Luca Bernardi. All rights reserved. 7 | // 8 | 9 | #import "UIImageView+LBBlurredImage.h" 10 | #import "UIImage+ImageEffects.h" 11 | 12 | CGFloat const kLBBlurredImageDefaultBlurRadius = 20.0; 13 | CGFloat const kLBBlurredImageDefaultSaturationDeltaFactor = 1.8; 14 | 15 | @implementation UIImageView (LBBlurredImage) 16 | 17 | #pragma mark - LBBlurredImage Additions 18 | 19 | - (void)setImageToBlur:(UIImage *)image 20 | completionBlock:(LBBlurredImageCompletionBlock)completion 21 | { 22 | [self setImageToBlur:image 23 | blurRadius:kLBBlurredImageDefaultBlurRadius 24 | completionBlock:completion]; 25 | } 26 | 27 | - (void)setImageToBlur:(UIImage *)image 28 | blurRadius:(CGFloat)blurRadius 29 | completionBlock:(LBBlurredImageCompletionBlock) completion 30 | { 31 | NSParameterAssert(image); 32 | NSParameterAssert(blurRadius >= 0); 33 | 34 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 35 | 36 | UIImage *blurredImage = [image applyBlurWithRadius:blurRadius 37 | tintColor:nil 38 | saturationDeltaFactor:kLBBlurredImageDefaultSaturationDeltaFactor 39 | maskImage:nil]; 40 | 41 | dispatch_async(dispatch_get_main_queue(), ^{ 42 | self.image = blurredImage; 43 | if (completion) { 44 | completion(); 45 | } 46 | }); 47 | }); 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/UIView+Extension.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Extension.h 3 | // EffectViewDemo 4 | // 5 | // Created by Arvin on 16/10/28. 6 | // Copyright © 2016年 Arvin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIView (Extension) 12 | @property (nonatomic, assign) CGFloat x; 13 | @property (nonatomic, assign) CGFloat y; 14 | @property (nonatomic, assign) CGFloat w; 15 | @property (nonatomic, assign) CGFloat h; 16 | @property (nonatomic, assign) CGSize size; 17 | @property (nonatomic, assign) CGFloat centerX; 18 | @property (nonatomic, assign) CGFloat centerY; 19 | @end 20 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/UIView+Extension.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Extension.m 3 | // EffectViewDemo 4 | // 5 | // Created by Arvin on 16/10/28. 6 | // Copyright © 2016年 Arvin. All rights reserved. 7 | // 8 | 9 | #import "UIView+Extension.h" 10 | 11 | @implementation UIView (Extension) 12 | 13 | - (void)setW:(CGFloat)w { 14 | CGRect frm = self.frame; 15 | frm.size.width = w; 16 | self.frame = frm; 17 | } 18 | - (CGFloat)w { 19 | return self.size.width; 20 | } 21 | 22 | - (void)setH:(CGFloat)h { 23 | CGRect frm = self.frame; 24 | frm.size.height = h; 25 | self.frame = frm; 26 | } 27 | - (CGFloat)h { 28 | return self.size.height; 29 | } 30 | 31 | - (void)setX:(CGFloat)x { 32 | CGRect org = self.frame; 33 | org.origin.x = x; 34 | self.frame = org; 35 | } 36 | - (CGFloat)x { 37 | return self.frame.origin.x; 38 | } 39 | 40 | - (void)setY:(CGFloat)y { 41 | CGRect org = self.frame; 42 | org.origin.y = y; 43 | self.frame = org; 44 | } 45 | - (CGFloat)y { 46 | return self.frame.origin.y; 47 | } 48 | 49 | - (void)setSize:(CGSize)size { 50 | self.bounds = CGRectMake(0, 0, size.width, size.height); 51 | } 52 | - (CGSize)size { 53 | return self.bounds.size; 54 | } 55 | 56 | - (void)setCenterX:(CGFloat)centerX { 57 | CGPoint center = self.center; 58 | center.x = centerX; 59 | self.center = center; 60 | } 61 | - (CGFloat)centerX { 62 | return self.center.x; 63 | } 64 | 65 | - (void)setCenterY:(CGFloat)centerY { 66 | CGPoint center = self.center; 67 | center.y = centerY; 68 | self.center = center; 69 | } 70 | - (CGFloat)centerY { 71 | return self.center.y; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // EffectViewDemo 4 | // 5 | // Created by Arvin on 16/1/14. 6 | // Copyright © 2016年 Arvin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // EffectViewDemo 4 | // 5 | // Created by Arvin on 16/1/14. 6 | // Copyright © 2016年 Arvin. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "UIView+Extension.h" 11 | #import "UIImageView+LBBlurredImage.h" 12 | 13 | #define FONT_SIZE 18 14 | #define kWIDTH [UIScreen mainScreen].bounds.size.width 15 | #define RGB(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)] 16 | 17 | @interface ViewController () 18 | 19 | @end 20 | 21 | @implementation ViewController 22 | 23 | 24 | - (void)viewDidLoad { 25 | 26 | [super viewDidLoad]; 27 | 28 | UIImageView *bgImgView = [[UIImageView alloc] init]; 29 | [bgImgView setFrame:self.view.bounds]; 30 | [bgImgView setUserInteractionEnabled:YES]; 31 | [bgImgView setContentMode:UIViewContentModeScaleAspectFill]; 32 | 33 | //------- 使用第三方工具类的方法请把这里的代码注释掉 -------// 34 | 35 | [bgImgView setImage:[UIImage imageNamed:@"huoying4.jpg"]]; 36 | [self.view addSubview:bgImgView]; 37 | 38 | // iOS7 UIToolbar 39 | [self toolbar:bgImgView]; 40 | 41 | // iOS8 UIBlurEffect 42 | [self blurEffect:bgImgView]; 43 | 44 | //-------------------------------------------------// 45 | 46 | // 使用第三方工具类 47 | //[self blurredImage:bgImgView]; 48 | 49 | // 头像 50 | UIImageView *headImgView = [[UIImageView alloc] init]; 51 | [bgImgView addSubview:({ 52 | [headImgView setUserInteractionEnabled:YES]; 53 | [headImgView setFrame:(CGRect){bgImgView.centerX-53, 80, 106, 106}]; 54 | [headImgView setImage:[UIImage imageNamed:@"huba.jpeg"]]; 55 | [headImgView setContentMode:UIViewContentModeScaleAspectFill]; 56 | [headImgView.layer setCornerRadius:CGRectGetHeight(headImgView.frame)*0.5]; 57 | [headImgView.layer setMasksToBounds:YES]; 58 | [headImgView.layer setBorderWidth:6.f]; 59 | [headImgView.layer setBorderColor:RGB(170, 170, 170, 0.5).CGColor]; 60 | [headImgView addGestureRecognizer:[[UITapGestureRecognizer alloc] 61 | initWithTarget:self action:@selector(headImgViewClick:)]]; 62 | headImgView; 63 | })]; 64 | 65 | // 签名 66 | [bgImgView addSubview:({ 67 | UILabel *lable = [[UILabel alloc] init]; 68 | [lable setText:@"我是测试签名"]; 69 | [lable setTextColor:[UIColor greenColor]]; 70 | [lable setTextAlignment:NSTextAlignmentCenter]; 71 | [lable setFont:[UIFont systemFontOfSize:FONT_SIZE]]; 72 | [lable setBackgroundColor:[UIColor orangeColor]]; 73 | CGSize lableSize = [lable.text boundingRectWithSize:CGSizeMake(MAXFLOAT,MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:FONT_SIZE]} context:nil].size; 74 | [lable setFrame:CGRectMake((kWIDTH*0.5)-(lableSize.width*0.5),CGRectGetMaxY(headImgView.frame)+15, lableSize.width, lableSize.height)]; 75 | [lable sizeToFit]; 76 | lable; 77 | })]; 78 | } 79 | 80 | - (void)toolbar:(UIImageView *)bgImgView { 81 | /** 82 | iOS7.0 83 | 毛玻璃的样式(枚举) 84 | UIBarStyleDefault = 0, 85 | UIBarStyleBlack = 1, 86 | UIBarStyleBlackOpaque = 1, // Deprecated. Use UIBarStyleBlack 87 | UIBarStyleBlackTranslucent = 2, // Deprecated. Use UIBarStyleBlack and set the translucent property to YES 88 | */ 89 | UIToolbar *toolbar = [[UIToolbar alloc] init]; 90 | toolbar.frame = (CGRect){0, 0, bgImgView.w * 0.5, bgImgView.h}; 91 | toolbar.barStyle = UIBarStyleBlackTranslucent; 92 | [bgImgView addSubview:toolbar]; 93 | 94 | CGRect frame = CGRectMake(0, bgImgView.h-80, kWIDTH * 0.5, 30); 95 | [bgImgView addSubview:[self labelWithFrame:frame text:@"iOS7-UIToolbar"]]; 96 | } 97 | 98 | 99 | - (void)blurEffect:(UIImageView *)bgImgView { 100 | /** 101 | iOS8.0 102 | 毛玻璃的样式(枚举) 103 | UIBlurEffectStyleExtraLight, 104 | UIBlurEffectStyleLight, 105 | UIBlurEffectStyleDark, 106 | 107 | // iOS 10新增的枚举值 108 | UIBlurEffectStyleRegular NS_ENUM_AVAILABLE_IOS(10_0), // Adapts to user interface style 109 | UIBlurEffectStyleProminent NS_ENUM_AVAILABLE_IOS(10_0), // Adapts to user interface style 110 | */ 111 | UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; 112 | UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect]; 113 | effectView.frame = CGRectMake(bgImgView.w * 0.5, 0, bgImgView.w * 0.5, bgImgView.h); 114 | [bgImgView addSubview:effectView]; 115 | 116 | CGRect frame = CGRectMake(kWIDTH * 0.5, bgImgView.h-80, kWIDTH * 0.5, 30); 117 | [bgImgView addSubview:[self labelWithFrame:frame text:@"iOS8-UIBlurEffect"]]; 118 | 119 | // 加上以下代码可以使毛玻璃特效更明亮点 120 | UIVibrancyEffect *vibrancyView = [UIVibrancyEffect effectForBlurEffect:effect]; 121 | UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyView]; 122 | visualEffectView.translatesAutoresizingMaskIntoConstraints = NO; 123 | [effectView.contentView addSubview:visualEffectView]; 124 | } 125 | 126 | 127 | - (void)blurredImage:(UIImageView *)bgImgView { 128 | // 方法1,没有blurRadius参数,因为默认是20 129 | //[bgImgView setImageToBlur:[UIImage imageNamed:@"huoying4.jpg"] completionBlock:nil]; 130 | 131 | // 方法2,对背景图片进行毛玻璃效果处理,参数blurRadius默认是20,可指定,最后一个参数block回调可为nil 132 | [bgImgView setImageToBlur:[UIImage imageNamed:@"huoying4.jpg"] blurRadius:35 completionBlock:nil]; 133 | [self.view addSubview:bgImgView]; 134 | 135 | CGRect frame = CGRectMake(0, bgImgView.h-80, kWIDTH, 30); 136 | [bgImgView addSubview:[self labelWithFrame:frame text:@"LBBlurredImage"]]; 137 | } 138 | 139 | 140 | - (UILabel *)labelWithFrame:(CGRect)frame text:(NSString *)text { 141 | UILabel *label = [[UILabel alloc] initWithFrame:frame]; 142 | label.text = text; 143 | label.textColor = [UIColor redColor]; 144 | label.textAlignment = NSTextAlignmentCenter; 145 | label.font = [UIFont systemFontOfSize:FONT_SIZE]; 146 | return label; 147 | } 148 | 149 | 150 | - (void)headImgViewClick:(UITapGestureRecognizer *)gesture { 151 | NSLog(@"%@->你点我干啥?",gesture); 152 | } 153 | 154 | 155 | - (void)didReceiveMemoryWarning { 156 | [super didReceiveMemoryWarning]; 157 | // Dispose of any resources that can be recreated. 158 | } 159 | 160 | @end 161 | -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/huba.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kejiasir/EffectViewDemo/dcb60d2b55723d10c2bea9813d6c65ccebb7a204/EffectViewDemo/EffectViewDemo/huba.jpeg -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/huoying4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kejiasir/EffectViewDemo/dcb60d2b55723d10c2bea9813d6c65ccebb7a204/EffectViewDemo/EffectViewDemo/huoying4.jpg -------------------------------------------------------------------------------- /EffectViewDemo/EffectViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // EffectViewDemo 4 | // 5 | // Created by Arvin on 16/1/14. 6 | // Copyright © 2016年 Arvin. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IMAGE/img_001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kejiasir/EffectViewDemo/dcb60d2b55723d10c2bea9813d6c65ccebb7a204/IMAGE/img_001.png -------------------------------------------------------------------------------- /IMAGE/img_002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kejiasir/EffectViewDemo/dcb60d2b55723d10c2bea9813d6c65ccebb7a204/IMAGE/img_002.png -------------------------------------------------------------------------------- /IMAGE/img_003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kejiasir/EffectViewDemo/dcb60d2b55723d10c2bea9813d6c65ccebb7a204/IMAGE/img_003.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## iOS 中实现毛玻璃(高斯模糊)的三种方式 2 | * 第一, iOS7之前, 使用系统的 `UIToolbar` 这个类来实现 3 | * 第二, iOS8之后, 官方新增了 `UIBlurEffect` 这个类来实现, 它其实是直接在图片上面盖了一层View 4 | * 第三, 使用第三方的框架, [LBBlurredImage](https://github.com/lukabernardi/LBBlurredImage) 这个框架内部是直接对图片进行了渲染处理的 5 | * 说明: 前面两个是官方的, 使用起来比较高效, 第三方的效果显然也没有那么好看, 大家还是看需求使用吧; 苹果推荐使用`UIBlurEffect` 6 | * demo 中都有详细的实现代码可以参考, 需要用到的朋友可以 Clone or download 下来看看 7 | 8 | ### 放几张效果图: 9 | * 第一张是用 `UIToolbar`实现的, 第二张是用`UIBlurEffect`实现的, 第三张是用`LBBlurredImage`实现的 10 | 11 | 12 | 15 | 18 | 21 | 22 |
13 | 14 | 16 | 17 | 19 | 20 |
23 | 24 | 25 | --------------------------------------------------------------------------------