├── .gitignore ├── CustomBlurEffectView.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── Example ├── AppDelegate.swift ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── Orange.imageset │ │ ├── Contents.json │ │ └── orange-king-of-fruits.jpg ├── Base.lproj │ └── LaunchScreen.storyboard ├── Info.plist └── ViewController.swift ├── LICENSE ├── Package.swift ├── README.md └── Sources └── CustomBlurEffectView ├── CustomBlurEffect.swift ├── CustomBlurEffectView.h ├── CustomBlurEffectView.swift ├── Info.plist └── UIVisualEffect+effectSettings.swift /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | xcuserdata/ 6 | -------------------------------------------------------------------------------- /CustomBlurEffectView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 322E2E2E2505F2C0005BD5BE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E2E2D2505F2C0005BD5BE /* AppDelegate.swift */; }; 11 | 322E2E322505F2C0005BD5BE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E2E312505F2C0005BD5BE /* ViewController.swift */; }; 12 | 322E2E342505F2C1005BD5BE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 322E2E332505F2C1005BD5BE /* Assets.xcassets */; }; 13 | 322E2E3A2505F2C1005BD5BE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 322E2E382505F2C1005BD5BE /* LaunchScreen.storyboard */; }; 14 | 322E2E4A2505F388005BD5BE /* CustomBlurEffectView.h in Headers */ = {isa = PBXBuildFile; fileRef = 322E2E482505F388005BD5BE /* CustomBlurEffectView.h */; settings = {ATTRIBUTES = (Public, ); }; }; 15 | 322E2E4D2505F388005BD5BE /* CustomBlurEffectView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 322E2E462505F388005BD5BE /* CustomBlurEffectView.framework */; }; 16 | 322E2E4E2505F388005BD5BE /* CustomBlurEffectView.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 322E2E462505F388005BD5BE /* CustomBlurEffectView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 17 | 322E2E542505F5A4005BD5BE /* CustomBlurEffectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E2E532505F5A4005BD5BE /* CustomBlurEffectView.swift */; }; 18 | 322E2E582505F8CC005BD5BE /* CustomBlurEffect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E2E572505F8CC005BD5BE /* CustomBlurEffect.swift */; }; 19 | 322E2E5A2505F8EB005BD5BE /* UIVisualEffect+effectSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E2E592505F8EB005BD5BE /* UIVisualEffect+effectSettings.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 322E2E4B2505F388005BD5BE /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 322E2E222505F2C0005BD5BE /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 322E2E452505F388005BD5BE; 28 | remoteInfo = CustomBlurEffectView; 29 | }; 30 | /* End PBXContainerItemProxy section */ 31 | 32 | /* Begin PBXCopyFilesBuildPhase section */ 33 | 322E2E522505F388005BD5BE /* Embed Frameworks */ = { 34 | isa = PBXCopyFilesBuildPhase; 35 | buildActionMask = 2147483647; 36 | dstPath = ""; 37 | dstSubfolderSpec = 10; 38 | files = ( 39 | 322E2E4E2505F388005BD5BE /* CustomBlurEffectView.framework in Embed Frameworks */, 40 | ); 41 | name = "Embed Frameworks"; 42 | runOnlyForDeploymentPostprocessing = 0; 43 | }; 44 | /* End PBXCopyFilesBuildPhase section */ 45 | 46 | /* Begin PBXFileReference section */ 47 | 322E2E2A2505F2C0005BD5BE /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | 322E2E2D2505F2C0005BD5BE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 49 | 322E2E312505F2C0005BD5BE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 50 | 322E2E332505F2C1005BD5BE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 51 | 322E2E392505F2C1005BD5BE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 52 | 322E2E3B2505F2C1005BD5BE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | 322E2E462505F388005BD5BE /* CustomBlurEffectView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CustomBlurEffectView.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 322E2E482505F388005BD5BE /* CustomBlurEffectView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CustomBlurEffectView.h; sourceTree = ""; }; 55 | 322E2E492505F388005BD5BE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | 322E2E532505F5A4005BD5BE /* CustomBlurEffectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomBlurEffectView.swift; sourceTree = ""; }; 57 | 322E2E572505F8CC005BD5BE /* CustomBlurEffect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomBlurEffect.swift; sourceTree = ""; }; 58 | 322E2E592505F8EB005BD5BE /* UIVisualEffect+effectSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIVisualEffect+effectSettings.swift"; sourceTree = ""; }; 59 | 32AAA9422508C43B004E3486 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 60 | /* End PBXFileReference section */ 61 | 62 | /* Begin PBXFrameworksBuildPhase section */ 63 | 322E2E272505F2C0005BD5BE /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | 322E2E4D2505F388005BD5BE /* CustomBlurEffectView.framework in Frameworks */, 68 | ); 69 | runOnlyForDeploymentPostprocessing = 0; 70 | }; 71 | 322E2E432505F388005BD5BE /* Frameworks */ = { 72 | isa = PBXFrameworksBuildPhase; 73 | buildActionMask = 2147483647; 74 | files = ( 75 | ); 76 | runOnlyForDeploymentPostprocessing = 0; 77 | }; 78 | /* End PBXFrameworksBuildPhase section */ 79 | 80 | /* Begin PBXGroup section */ 81 | 322E2E212505F2C0005BD5BE = { 82 | isa = PBXGroup; 83 | children = ( 84 | 32AAA9422508C43B004E3486 /* README.md */, 85 | 322E2E2C2505F2C0005BD5BE /* Example */, 86 | 322E2E472505F388005BD5BE /* CustomBlurEffectView */, 87 | 322E2E2B2505F2C0005BD5BE /* Products */, 88 | ); 89 | sourceTree = ""; 90 | }; 91 | 322E2E2B2505F2C0005BD5BE /* Products */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 322E2E2A2505F2C0005BD5BE /* Example.app */, 95 | 322E2E462505F388005BD5BE /* CustomBlurEffectView.framework */, 96 | ); 97 | name = Products; 98 | sourceTree = ""; 99 | }; 100 | 322E2E2C2505F2C0005BD5BE /* Example */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | 322E2E2D2505F2C0005BD5BE /* AppDelegate.swift */, 104 | 322E2E312505F2C0005BD5BE /* ViewController.swift */, 105 | 322E2E332505F2C1005BD5BE /* Assets.xcassets */, 106 | 322E2E382505F2C1005BD5BE /* LaunchScreen.storyboard */, 107 | 322E2E3B2505F2C1005BD5BE /* Info.plist */, 108 | ); 109 | path = Example; 110 | sourceTree = ""; 111 | }; 112 | 322E2E472505F388005BD5BE /* CustomBlurEffectView */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 322E2E532505F5A4005BD5BE /* CustomBlurEffectView.swift */, 116 | 322E2E572505F8CC005BD5BE /* CustomBlurEffect.swift */, 117 | 322E2E592505F8EB005BD5BE /* UIVisualEffect+effectSettings.swift */, 118 | 322E2E482505F388005BD5BE /* CustomBlurEffectView.h */, 119 | 322E2E492505F388005BD5BE /* Info.plist */, 120 | ); 121 | name = CustomBlurEffectView; 122 | path = Sources/CustomBlurEffectView; 123 | sourceTree = ""; 124 | }; 125 | /* End PBXGroup section */ 126 | 127 | /* Begin PBXHeadersBuildPhase section */ 128 | 322E2E412505F388005BD5BE /* Headers */ = { 129 | isa = PBXHeadersBuildPhase; 130 | buildActionMask = 2147483647; 131 | files = ( 132 | 322E2E4A2505F388005BD5BE /* CustomBlurEffectView.h in Headers */, 133 | ); 134 | runOnlyForDeploymentPostprocessing = 0; 135 | }; 136 | /* End PBXHeadersBuildPhase section */ 137 | 138 | /* Begin PBXNativeTarget section */ 139 | 322E2E292505F2C0005BD5BE /* Example */ = { 140 | isa = PBXNativeTarget; 141 | buildConfigurationList = 322E2E3E2505F2C1005BD5BE /* Build configuration list for PBXNativeTarget "Example" */; 142 | buildPhases = ( 143 | 322E2E262505F2C0005BD5BE /* Sources */, 144 | 322E2E272505F2C0005BD5BE /* Frameworks */, 145 | 322E2E282505F2C0005BD5BE /* Resources */, 146 | 322E2E522505F388005BD5BE /* Embed Frameworks */, 147 | ); 148 | buildRules = ( 149 | ); 150 | dependencies = ( 151 | 322E2E4C2505F388005BD5BE /* PBXTargetDependency */, 152 | ); 153 | name = Example; 154 | productName = CustomBlurEffectView; 155 | productReference = 322E2E2A2505F2C0005BD5BE /* Example.app */; 156 | productType = "com.apple.product-type.application"; 157 | }; 158 | 322E2E452505F388005BD5BE /* CustomBlurEffectView */ = { 159 | isa = PBXNativeTarget; 160 | buildConfigurationList = 322E2E4F2505F388005BD5BE /* Build configuration list for PBXNativeTarget "CustomBlurEffectView" */; 161 | buildPhases = ( 162 | 322E2E412505F388005BD5BE /* Headers */, 163 | 322E2E422505F388005BD5BE /* Sources */, 164 | 322E2E432505F388005BD5BE /* Frameworks */, 165 | 322E2E442505F388005BD5BE /* Resources */, 166 | ); 167 | buildRules = ( 168 | ); 169 | dependencies = ( 170 | ); 171 | name = CustomBlurEffectView; 172 | productName = CustomBlurEffectView; 173 | productReference = 322E2E462505F388005BD5BE /* CustomBlurEffectView.framework */; 174 | productType = "com.apple.product-type.framework"; 175 | }; 176 | /* End PBXNativeTarget section */ 177 | 178 | /* Begin PBXProject section */ 179 | 322E2E222505F2C0005BD5BE /* Project object */ = { 180 | isa = PBXProject; 181 | attributes = { 182 | LastSwiftUpdateCheck = 1200; 183 | LastUpgradeCheck = 1200; 184 | TargetAttributes = { 185 | 322E2E292505F2C0005BD5BE = { 186 | CreatedOnToolsVersion = 12.0; 187 | }; 188 | 322E2E452505F388005BD5BE = { 189 | CreatedOnToolsVersion = 12.0; 190 | LastSwiftMigration = 1200; 191 | }; 192 | }; 193 | }; 194 | buildConfigurationList = 322E2E252505F2C0005BD5BE /* Build configuration list for PBXProject "CustomBlurEffectView" */; 195 | compatibilityVersion = "Xcode 9.3"; 196 | developmentRegion = en; 197 | hasScannedForEncodings = 0; 198 | knownRegions = ( 199 | en, 200 | Base, 201 | ); 202 | mainGroup = 322E2E212505F2C0005BD5BE; 203 | productRefGroup = 322E2E2B2505F2C0005BD5BE /* Products */; 204 | projectDirPath = ""; 205 | projectRoot = ""; 206 | targets = ( 207 | 322E2E292505F2C0005BD5BE /* Example */, 208 | 322E2E452505F388005BD5BE /* CustomBlurEffectView */, 209 | ); 210 | }; 211 | /* End PBXProject section */ 212 | 213 | /* Begin PBXResourcesBuildPhase section */ 214 | 322E2E282505F2C0005BD5BE /* Resources */ = { 215 | isa = PBXResourcesBuildPhase; 216 | buildActionMask = 2147483647; 217 | files = ( 218 | 322E2E3A2505F2C1005BD5BE /* LaunchScreen.storyboard in Resources */, 219 | 322E2E342505F2C1005BD5BE /* Assets.xcassets in Resources */, 220 | ); 221 | runOnlyForDeploymentPostprocessing = 0; 222 | }; 223 | 322E2E442505F388005BD5BE /* Resources */ = { 224 | isa = PBXResourcesBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | ); 228 | runOnlyForDeploymentPostprocessing = 0; 229 | }; 230 | /* End PBXResourcesBuildPhase section */ 231 | 232 | /* Begin PBXSourcesBuildPhase section */ 233 | 322E2E262505F2C0005BD5BE /* Sources */ = { 234 | isa = PBXSourcesBuildPhase; 235 | buildActionMask = 2147483647; 236 | files = ( 237 | 322E2E2E2505F2C0005BD5BE /* AppDelegate.swift in Sources */, 238 | 322E2E322505F2C0005BD5BE /* ViewController.swift in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | 322E2E422505F388005BD5BE /* Sources */ = { 243 | isa = PBXSourcesBuildPhase; 244 | buildActionMask = 2147483647; 245 | files = ( 246 | 322E2E582505F8CC005BD5BE /* CustomBlurEffect.swift in Sources */, 247 | 322E2E542505F5A4005BD5BE /* CustomBlurEffectView.swift in Sources */, 248 | 322E2E5A2505F8EB005BD5BE /* UIVisualEffect+effectSettings.swift in Sources */, 249 | ); 250 | runOnlyForDeploymentPostprocessing = 0; 251 | }; 252 | /* End PBXSourcesBuildPhase section */ 253 | 254 | /* Begin PBXTargetDependency section */ 255 | 322E2E4C2505F388005BD5BE /* PBXTargetDependency */ = { 256 | isa = PBXTargetDependency; 257 | target = 322E2E452505F388005BD5BE /* CustomBlurEffectView */; 258 | targetProxy = 322E2E4B2505F388005BD5BE /* PBXContainerItemProxy */; 259 | }; 260 | /* End PBXTargetDependency section */ 261 | 262 | /* Begin PBXVariantGroup section */ 263 | 322E2E382505F2C1005BD5BE /* LaunchScreen.storyboard */ = { 264 | isa = PBXVariantGroup; 265 | children = ( 266 | 322E2E392505F2C1005BD5BE /* Base */, 267 | ); 268 | name = LaunchScreen.storyboard; 269 | sourceTree = ""; 270 | }; 271 | /* End PBXVariantGroup section */ 272 | 273 | /* Begin XCBuildConfiguration section */ 274 | 322E2E3C2505F2C1005BD5BE /* Debug */ = { 275 | isa = XCBuildConfiguration; 276 | buildSettings = { 277 | ALWAYS_SEARCH_USER_PATHS = NO; 278 | CLANG_ANALYZER_NONNULL = YES; 279 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 280 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 281 | CLANG_CXX_LIBRARY = "libc++"; 282 | CLANG_ENABLE_MODULES = YES; 283 | CLANG_ENABLE_OBJC_ARC = YES; 284 | CLANG_ENABLE_OBJC_WEAK = YES; 285 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 286 | CLANG_WARN_BOOL_CONVERSION = YES; 287 | CLANG_WARN_COMMA = YES; 288 | CLANG_WARN_CONSTANT_CONVERSION = YES; 289 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 290 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 291 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 292 | CLANG_WARN_EMPTY_BODY = YES; 293 | CLANG_WARN_ENUM_CONVERSION = YES; 294 | CLANG_WARN_INFINITE_RECURSION = YES; 295 | CLANG_WARN_INT_CONVERSION = YES; 296 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 297 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 298 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 299 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 300 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 301 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 302 | CLANG_WARN_STRICT_PROTOTYPES = YES; 303 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 304 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 305 | CLANG_WARN_UNREACHABLE_CODE = YES; 306 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 307 | COPY_PHASE_STRIP = NO; 308 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 309 | ENABLE_STRICT_OBJC_MSGSEND = YES; 310 | ENABLE_TESTABILITY = YES; 311 | GCC_C_LANGUAGE_STANDARD = gnu11; 312 | GCC_DYNAMIC_NO_PIC = NO; 313 | GCC_NO_COMMON_BLOCKS = YES; 314 | GCC_OPTIMIZATION_LEVEL = 0; 315 | GCC_PREPROCESSOR_DEFINITIONS = ( 316 | "DEBUG=1", 317 | "$(inherited)", 318 | ); 319 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 320 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 321 | GCC_WARN_UNDECLARED_SELECTOR = YES; 322 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 323 | GCC_WARN_UNUSED_FUNCTION = YES; 324 | GCC_WARN_UNUSED_VARIABLE = YES; 325 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 326 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 327 | MTL_FAST_MATH = YES; 328 | ONLY_ACTIVE_ARCH = YES; 329 | SDKROOT = iphoneos; 330 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 331 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 332 | TARGETED_DEVICE_FAMILY = "1,2"; 333 | }; 334 | name = Debug; 335 | }; 336 | 322E2E3D2505F2C1005BD5BE /* Release */ = { 337 | isa = XCBuildConfiguration; 338 | buildSettings = { 339 | ALWAYS_SEARCH_USER_PATHS = NO; 340 | CLANG_ANALYZER_NONNULL = YES; 341 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 342 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 343 | CLANG_CXX_LIBRARY = "libc++"; 344 | CLANG_ENABLE_MODULES = YES; 345 | CLANG_ENABLE_OBJC_ARC = YES; 346 | CLANG_ENABLE_OBJC_WEAK = YES; 347 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 348 | CLANG_WARN_BOOL_CONVERSION = YES; 349 | CLANG_WARN_COMMA = YES; 350 | CLANG_WARN_CONSTANT_CONVERSION = YES; 351 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 352 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 353 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 354 | CLANG_WARN_EMPTY_BODY = YES; 355 | CLANG_WARN_ENUM_CONVERSION = YES; 356 | CLANG_WARN_INFINITE_RECURSION = YES; 357 | CLANG_WARN_INT_CONVERSION = YES; 358 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 359 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 360 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 361 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 362 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 363 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 364 | CLANG_WARN_STRICT_PROTOTYPES = YES; 365 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 366 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 367 | CLANG_WARN_UNREACHABLE_CODE = YES; 368 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 369 | COPY_PHASE_STRIP = NO; 370 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 371 | ENABLE_NS_ASSERTIONS = NO; 372 | ENABLE_STRICT_OBJC_MSGSEND = YES; 373 | GCC_C_LANGUAGE_STANDARD = gnu11; 374 | GCC_NO_COMMON_BLOCKS = YES; 375 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 376 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 377 | GCC_WARN_UNDECLARED_SELECTOR = YES; 378 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 379 | GCC_WARN_UNUSED_FUNCTION = YES; 380 | GCC_WARN_UNUSED_VARIABLE = YES; 381 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 382 | MTL_ENABLE_DEBUG_INFO = NO; 383 | MTL_FAST_MATH = YES; 384 | SDKROOT = iphoneos; 385 | SWIFT_COMPILATION_MODE = wholemodule; 386 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 387 | TARGETED_DEVICE_FAMILY = "1,2"; 388 | VALIDATE_PRODUCT = YES; 389 | }; 390 | name = Release; 391 | }; 392 | 322E2E3F2505F2C1005BD5BE /* Debug */ = { 393 | isa = XCBuildConfiguration; 394 | buildSettings = { 395 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 396 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 397 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 398 | CODE_SIGN_STYLE = Automatic; 399 | DEVELOPMENT_TEAM = 7BQD2UT5UF; 400 | ENABLE_PREVIEWS = YES; 401 | INFOPLIST_FILE = Example/Info.plist; 402 | LD_RUNPATH_SEARCH_PATHS = ( 403 | "$(inherited)", 404 | "@executable_path/Frameworks", 405 | ); 406 | PRODUCT_BUNDLE_IDENTIFIER = perfectdim.CustomBlurEffectView.Example; 407 | PRODUCT_NAME = "$(TARGET_NAME)"; 408 | SWIFT_VERSION = 5.0; 409 | }; 410 | name = Debug; 411 | }; 412 | 322E2E402505F2C1005BD5BE /* Release */ = { 413 | isa = XCBuildConfiguration; 414 | buildSettings = { 415 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 416 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 417 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 418 | CODE_SIGN_STYLE = Automatic; 419 | DEVELOPMENT_TEAM = 7BQD2UT5UF; 420 | ENABLE_PREVIEWS = YES; 421 | INFOPLIST_FILE = Example/Info.plist; 422 | LD_RUNPATH_SEARCH_PATHS = ( 423 | "$(inherited)", 424 | "@executable_path/Frameworks", 425 | ); 426 | PRODUCT_BUNDLE_IDENTIFIER = perfectdim.CustomBlurEffectView.Example; 427 | PRODUCT_NAME = "$(TARGET_NAME)"; 428 | SWIFT_VERSION = 5.0; 429 | }; 430 | name = Release; 431 | }; 432 | 322E2E502505F388005BD5BE /* Debug */ = { 433 | isa = XCBuildConfiguration; 434 | buildSettings = { 435 | CLANG_ENABLE_MODULES = YES; 436 | CODE_SIGN_STYLE = Manual; 437 | CURRENT_PROJECT_VERSION = 1; 438 | DEFINES_MODULE = YES; 439 | DEVELOPMENT_TEAM = ""; 440 | DYLIB_COMPATIBILITY_VERSION = 1; 441 | DYLIB_CURRENT_VERSION = 1; 442 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 443 | INFOPLIST_FILE = Sources/CustomBlurEffectView/Info.plist; 444 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 445 | LD_RUNPATH_SEARCH_PATHS = ( 446 | "$(inherited)", 447 | "@executable_path/Frameworks", 448 | "@loader_path/Frameworks", 449 | ); 450 | PRODUCT_BUNDLE_IDENTIFIER = perfectdim.CustomBlurEffectView; 451 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 452 | PROVISIONING_PROFILE_SPECIFIER = ""; 453 | "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; 454 | SKIP_INSTALL = YES; 455 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 456 | SWIFT_VERSION = 5.0; 457 | VERSIONING_SYSTEM = "apple-generic"; 458 | VERSION_INFO_PREFIX = ""; 459 | }; 460 | name = Debug; 461 | }; 462 | 322E2E512505F388005BD5BE /* Release */ = { 463 | isa = XCBuildConfiguration; 464 | buildSettings = { 465 | CLANG_ENABLE_MODULES = YES; 466 | CODE_SIGN_STYLE = Manual; 467 | CURRENT_PROJECT_VERSION = 1; 468 | DEFINES_MODULE = YES; 469 | DEVELOPMENT_TEAM = ""; 470 | DYLIB_COMPATIBILITY_VERSION = 1; 471 | DYLIB_CURRENT_VERSION = 1; 472 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 473 | INFOPLIST_FILE = Sources/CustomBlurEffectView/Info.plist; 474 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 475 | LD_RUNPATH_SEARCH_PATHS = ( 476 | "$(inherited)", 477 | "@executable_path/Frameworks", 478 | "@loader_path/Frameworks", 479 | ); 480 | PRODUCT_BUNDLE_IDENTIFIER = perfectdim.CustomBlurEffectView; 481 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 482 | PROVISIONING_PROFILE_SPECIFIER = ""; 483 | "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; 484 | SKIP_INSTALL = YES; 485 | SWIFT_VERSION = 5.0; 486 | VERSIONING_SYSTEM = "apple-generic"; 487 | VERSION_INFO_PREFIX = ""; 488 | }; 489 | name = Release; 490 | }; 491 | /* End XCBuildConfiguration section */ 492 | 493 | /* Begin XCConfigurationList section */ 494 | 322E2E252505F2C0005BD5BE /* Build configuration list for PBXProject "CustomBlurEffectView" */ = { 495 | isa = XCConfigurationList; 496 | buildConfigurations = ( 497 | 322E2E3C2505F2C1005BD5BE /* Debug */, 498 | 322E2E3D2505F2C1005BD5BE /* Release */, 499 | ); 500 | defaultConfigurationIsVisible = 0; 501 | defaultConfigurationName = Release; 502 | }; 503 | 322E2E3E2505F2C1005BD5BE /* Build configuration list for PBXNativeTarget "Example" */ = { 504 | isa = XCConfigurationList; 505 | buildConfigurations = ( 506 | 322E2E3F2505F2C1005BD5BE /* Debug */, 507 | 322E2E402505F2C1005BD5BE /* Release */, 508 | ); 509 | defaultConfigurationIsVisible = 0; 510 | defaultConfigurationName = Release; 511 | }; 512 | 322E2E4F2505F388005BD5BE /* Build configuration list for PBXNativeTarget "CustomBlurEffectView" */ = { 513 | isa = XCConfigurationList; 514 | buildConfigurations = ( 515 | 322E2E502505F388005BD5BE /* Debug */, 516 | 322E2E512505F388005BD5BE /* Release */, 517 | ); 518 | defaultConfigurationIsVisible = 0; 519 | defaultConfigurationName = Release; 520 | }; 521 | /* End XCConfigurationList section */ 522 | }; 523 | rootObject = 322E2E222505F2C0005BD5BE /* Project object */; 524 | } 525 | -------------------------------------------------------------------------------- /CustomBlurEffectView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CustomBlurEffectView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CustomBlurEffectView 4 | // 5 | // Created by Kononec Dmitrii on 07.09.2020. 6 | // 7 | 8 | import UIKit 9 | 10 | @UIApplicationMain 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | 17 | self.window = UIWindow(frame: UIScreen.main.bounds) 18 | self.window?.rootViewController = ViewController() 19 | self.window?.makeKeyAndVisible() 20 | 21 | 22 | return true 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Example/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Example/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Assets.xcassets/Orange.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "orange-king-of-fruits.jpg", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/Assets.xcassets/Orange.imageset/orange-king-of-fruits.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/perfectdim/CustomBlurEffectView/a25e92fc90c0df9bdf79177974ba8581ea470905/Example/Assets.xcassets/Orange.imageset/orange-king-of-fruits.jpg -------------------------------------------------------------------------------- /Example/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 | -------------------------------------------------------------------------------- /Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSupportsIndirectInputEvents 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Example/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // CustomBlurEffectView 4 | // 5 | // Created by Kononec Dmitrii on 07.09.2020. 6 | // 7 | 8 | import UIKit 9 | import CustomBlurEffectView 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | setupViews() 16 | } 17 | 18 | private let colors: [UIColor] = [ 19 | .red, 20 | .cyan, 21 | .black, 22 | .blue, 23 | .clear, 24 | .green, 25 | .yellow 26 | ] 27 | 28 | private lazy var backgroundImage: UIImageView = { 29 | let view = UIImageView(image: UIImage(named: "Orange")) 30 | view.translatesAutoresizingMaskIntoConstraints = false 31 | view.contentMode = .scaleAspectFill 32 | return view 33 | }() 34 | 35 | private lazy var stackView: UIStackView = { 36 | let view = UIStackView(arrangedSubviews: blurEffectViews) 37 | view.translatesAutoresizingMaskIntoConstraints = false 38 | view.alignment = .fill 39 | view.axis = .vertical 40 | view.distribution = .fillEqually 41 | return view 42 | }() 43 | 44 | private lazy var blurEffectViews: [CustomBlurEffectView] = { 45 | var views = [CustomBlurEffectView]() 46 | colors.forEach { color in 47 | let blurEffectView = CustomBlurEffectView(radius: 5, color: color, colorAlpha: 0.8) 48 | views.append(blurEffectView) 49 | } 50 | return views 51 | }() 52 | 53 | private lazy var blurRadiusSlider: UISlider = { 54 | let slider = UISlider() 55 | slider.translatesAutoresizingMaskIntoConstraints = false 56 | slider.thumbTintColor = .black 57 | slider.minimumTrackTintColor = .yellow 58 | slider.maximumTrackTintColor = .red 59 | slider.minimumValue = 0.0 60 | slider.maximumValue = 20.0 61 | slider.value = 10 62 | slider.addTarget(self, action: #selector(blurRadiusSliderChange), for: .valueChanged) 63 | return slider 64 | }() 65 | 66 | @objc 67 | private func blurRadiusSliderChange() { 68 | let newValue = CGFloat(blurRadiusSlider.value) 69 | blurEffectViews.forEach({$0.blurRadius = newValue}) 70 | } 71 | 72 | private lazy var colorTintOpacitySlider: UISlider = { 73 | let slider = UISlider() 74 | slider.translatesAutoresizingMaskIntoConstraints = false 75 | slider.thumbTintColor = .black 76 | slider.minimumTrackTintColor = .yellow 77 | slider.maximumTrackTintColor = .red 78 | slider.minimumValue = 0.0 79 | slider.maximumValue = 1.0 80 | slider.value = 0.8 81 | slider.addTarget(self, action: #selector(colorTintOpacitySliderChange), for: .valueChanged) 82 | return slider 83 | }() 84 | 85 | @objc 86 | private func colorTintOpacitySliderChange() { 87 | let newValue = CGFloat(colorTintOpacitySlider.value) 88 | blurEffectViews.forEach({$0.colorTintAlpha = newValue}) 89 | } 90 | 91 | private func setupViews() { 92 | view.addSubview(backgroundImage) 93 | toEdges(view: backgroundImage) 94 | view.addSubview(stackView) 95 | toEdges(view: stackView) 96 | 97 | view.addSubview(blurRadiusSlider) 98 | NSLayoutConstraint.activate([ 99 | blurRadiusSlider.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 15), 100 | blurRadiusSlider.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -15), 101 | blurRadiusSlider.heightAnchor.constraint(equalToConstant: 50), 102 | blurRadiusSlider.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -40), 103 | ]) 104 | 105 | view.addSubview(colorTintOpacitySlider) 106 | NSLayoutConstraint.activate([ 107 | colorTintOpacitySlider.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 15), 108 | colorTintOpacitySlider.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -15), 109 | colorTintOpacitySlider.heightAnchor.constraint(equalToConstant: 50), 110 | colorTintOpacitySlider.bottomAnchor.constraint(equalTo: blurRadiusSlider.topAnchor, constant: -20), 111 | ]) 112 | } 113 | 114 | private func toEdges(view: UIView) { 115 | NSLayoutConstraint.activate([ 116 | self.view.topAnchor.constraint(equalTo: view.topAnchor), 117 | self.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), 118 | self.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), 119 | self.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), 120 | ]) 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Dmitrii Kononec 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 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.2 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "CustomBlurEffectView", 7 | platforms: [ 8 | .iOS(.v9) 9 | ], 10 | products: [ 11 | .library( 12 | name: "CustomBlurEffectView", 13 | targets: ["CustomBlurEffectView"]), 14 | ], 15 | dependencies: [ 16 | ], 17 | targets: [ 18 | .target( 19 | name: "CustomBlurEffectView", 20 | dependencies: []), 21 | ] 22 | ) 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CustomBlurEffectView 2 | Customizable blur effect view with blur radius, tint color and tint color alpha. 3 | 4 | [![Version](https://img.shields.io/github/v/tag/perfectdim/CustomBlurEffectView)]() 5 | [![Language](https://img.shields.io/badge/Swift-5-orange)](https://swift.org) 6 | [![License](https://img.shields.io/github/license/perfectdim/CustomBlurEffectView)](https://github.com/perfectdim/CustomBlurEffectView/blob/master/LICENSE) 7 | 8 | **CustomBlurEffectView** is a customizable blur effect view with blur radius, tint color and tint color alpha. This library uses the [UIVisualEffectView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIVisualEffectView/) to generate the blur. 9 | 10 | ![Demo GIF](https://thumbs.gfycat.com/LimitedSorrowfulBellfrog-small.gif) 11 | 12 | ## Requirements 13 | 14 | - iOS 9.0+ 15 | - Xcode 9.0+ 16 | - Swift 5 17 | 18 | --- 19 | 20 | ## Usage 21 | 22 | Add an instance of CustomBlurEffectView to your view. 23 | 24 | ```swift 25 | import CustomBlurEffectView 26 | 27 | let customBlurEffectView = CustomBlurEffectView( 28 | radius: 20, // Set blur radius value. Defaults to `10` (CGFloat) 29 | color: .cyan, // Set tint color value. Defaults to `nil` (UIColor?) 30 | colorAlpha: 0.4 // Set tint color alpha value. Defaults to `0.8` (CGFloat) 31 | ) 32 | customBlurEffectView.frame = CGRect(x: 0, y: 0, width: 300, height: 300) 33 | addSubview(customBlurEffectView) 34 | ``` 35 | 36 | Either you can configure the view different way. 37 | ```swift 38 | let customBlurEffectView = CustomBlurEffectView() 39 | customBlurEffectView.frame = CGRect(x: 0, y: 0, width: 300, height: 300) 40 | customBlurEffectView.blurRadius = 20 41 | customBlurEffectView.colorTint = .cyan 42 | customBlurEffectView.colorTintAlpha = 0.4 43 | addSubview(customBlurEffectView) 44 | ``` 45 | 46 | CustomBlurEffectView is inherited from UIView, and UIVisualEffectView is a subview of CustomBlurEffectView. To get UIVisualEffectView layer directly you can use `blurLayer` property: 47 | ```swift 48 | let customBlurEffectView = CustomBlurEffectView() 49 | let layer = customBlurEffectView.blurLayer 50 | ``` 51 | 52 | For more examples, take a look at the example project. 53 | 54 | --- 55 | 56 | ## Installation 57 | 58 | ### Swift Package Manager 59 | 60 | In Xcode, select File ▸ Swift Packages ▸ Add Package Dependency…. Select target. Copy the following and paste into the combined search box: 61 | 62 | ``` 63 | https://github.com/perfectdim/CustomBlurEffectView.git 64 | ``` 65 | 66 | Click Next. Choose Package Options screen with Version selected under Rules and Up to next Major and 1.0.0 selected in dropdowns. Click Next. 67 | 68 | Xcode downloads the code from GitHub. Click Finish. 69 | 70 | #### OR 71 | 72 | In your Package.swift: 73 | 74 | ```swift 75 | let package = Package( 76 | name: "Example", 77 | dependencies: [ 78 | .package(url: "https://github.com/perfectdim/CustomBlurEffectView.git", from: "0.0.1") 79 | ], 80 | targets: [ 81 | .target(name: "Example", dependencies: ["CustomBlurEffectView"]) 82 | ] 83 | ) 84 | ``` 85 | 86 | Note that there’s now a Swift Package Dependencies section in the Project Navigator on the left and a Swift Packages tab in the Project settings. 87 | 88 | ### Manually 89 | 90 | 1. Download and drop `CustomBlurEffectView.swift`, `CustomBlurEffect.swift`, `UIVisualEffect+effectSettings.swift` in to your project. 91 | 2. Done! 92 | 93 | --- 94 | 95 | ## Communication 96 | 97 | - If you **found a bug**, open an issue. 98 | - If you **have a feature request**, open an issue. 99 | - If you **want to contribute**, submit a pull request. 100 | 101 | ## Disclaimer 102 | 103 | CustomBlurEffectView utilizes a private UIKit API to do its magic. Use caution, submitting this code to the App Store adds the risk of being rejected! 104 | 105 | ## Credits 106 | 107 | https://github.com/efremidze/VisualEffectView 108 | 109 | ## License 110 | 111 | CustomBlurEffectView is available under the MIT license. See the LICENSE file for more info. 112 | -------------------------------------------------------------------------------- /Sources/CustomBlurEffectView/CustomBlurEffect.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomBlurEffect.swift 3 | // CustomBlurEffectView 4 | // 5 | // Created by Kononec Dmitrii on 07.09.2020. 6 | // 7 | 8 | import UIKit 9 | 10 | class CustomBlurEffect: UIBlurEffect { 11 | 12 | public var blurRadius: CGFloat = 10.0 13 | 14 | private enum Constants { 15 | static let blurRadiusSettingKey = "blurRadius" 16 | } 17 | 18 | class func effect(with style: UIBlurEffect.Style) -> CustomBlurEffect { 19 | let result = super.init(style: style) 20 | object_setClass(result, self) 21 | return result as! CustomBlurEffect 22 | } 23 | 24 | override func copy(with zone: NSZone? = nil) -> Any { 25 | let result = super.copy(with: zone) 26 | object_setClass(result, Self.self) 27 | return result 28 | } 29 | 30 | override var effectSettings: AnyObject { 31 | get { 32 | let settings = super.effectSettings 33 | settings.setValue(blurRadius, forKey: Constants.blurRadiusSettingKey) 34 | return settings 35 | } 36 | set { 37 | super.effectSettings = newValue 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Sources/CustomBlurEffectView/CustomBlurEffectView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CustomBlurEffectView.h 3 | // CustomBlurEffectView 4 | // 5 | // Created by Kononec Dmitrii on 07.09.2020. 6 | // 7 | 8 | #import 9 | 10 | //! Project version number for CustomBlurEffectView. 11 | FOUNDATION_EXPORT double CustomBlurEffectViewVersionNumber; 12 | 13 | //! Project version string for CustomBlurEffectView. 14 | FOUNDATION_EXPORT const unsigned char CustomBlurEffectViewVersionString[]; 15 | 16 | // In this header, you should import all the public headers of your framework using statements like #import 17 | 18 | 19 | -------------------------------------------------------------------------------- /Sources/CustomBlurEffectView/CustomBlurEffectView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomBlurEffectView.swift 3 | // CustomBlurEffectView 4 | // 5 | // Created by Kononec Dmitrii on 07.09.2020. 6 | // 7 | 8 | import UIKit 9 | 10 | open class CustomBlurEffectView: UIView { 11 | 12 | private enum Constants { 13 | static let blurRadiusKey = "blurRadius" 14 | static let colorTintKey = "colorTint" 15 | static let colorTintAlphaKey = "colorTintAlpha" 16 | } 17 | 18 | // MARK: - Public 19 | 20 | /// Blur radius. Defaults to `10` 21 | open var blurRadius: CGFloat = 10.0 { 22 | didSet { 23 | _setValue(blurRadius, forKey: Constants.blurRadiusKey) 24 | } 25 | } 26 | 27 | /// Tint color. Defaults to `nil` 28 | open var colorTint: UIColor? { 29 | didSet { 30 | _setValue(colorTint, forKey: Constants.colorTintKey) 31 | } 32 | } 33 | 34 | /// Tint color alpha. Defaults to `0.8` 35 | open var colorTintAlpha: CGFloat = 0.8 { 36 | didSet { 37 | _setValue(colorTintAlpha, forKey: Constants.colorTintAlphaKey) 38 | } 39 | } 40 | 41 | /// Visual effect view layer. 42 | public var blurLayer: CALayer { 43 | return visualEffectView.layer 44 | } 45 | 46 | // MARK: - Initialization 47 | 48 | public init( 49 | radius: CGFloat = 10.0, 50 | color: UIColor? = nil, 51 | colorAlpha: CGFloat = 0.8) { 52 | blurRadius = radius 53 | super.init(frame: .zero) 54 | backgroundColor = .clear 55 | setupViews() 56 | defer { 57 | blurRadius = radius 58 | colorTint = color 59 | colorTintAlpha = colorAlpha 60 | } 61 | } 62 | 63 | required public init?(coder: NSCoder) { 64 | super.init(coder: coder) 65 | backgroundColor = .clear 66 | setupViews() 67 | defer { 68 | blurRadius = 10.0 69 | colorTint = nil 70 | colorTintAlpha = 0.8 71 | } 72 | } 73 | 74 | 75 | // MARK: - Private 76 | 77 | /// Visual effect view. 78 | private lazy var visualEffectView: UIVisualEffectView = { 79 | if #available(iOS 14.0, *) { 80 | return UIVisualEffectView(effect: customBlurEffect_ios14) 81 | } else { 82 | return UIVisualEffectView(effect: customBlurEffect) 83 | } 84 | }() 85 | 86 | /// Blur effect for IOS >= 14 87 | private lazy var customBlurEffect_ios14: CustomBlurEffect = { 88 | let effect = CustomBlurEffect.effect(with: .extraLight) 89 | effect.blurRadius = blurRadius 90 | return effect 91 | }() 92 | 93 | /// Blur effect for IOS < 14 94 | private lazy var customBlurEffect: UIBlurEffect = { 95 | return (NSClassFromString("_UICustomBlurEffect") as! UIBlurEffect.Type).init() 96 | }() 97 | 98 | /// Sets the value for the key on the blurEffect. 99 | private func _setValue(_ value: Any?, forKey key: String) { 100 | if #available(iOS 14.0, *) { 101 | if key == Constants.blurRadiusKey { 102 | updateViews() 103 | } 104 | let subviewClass = NSClassFromString("_UIVisualEffectSubview") as? UIView.Type 105 | let visualEffectSubview: UIView? = visualEffectView.subviews.filter({ type(of: $0) == subviewClass }).first 106 | visualEffectSubview?.backgroundColor = colorTint 107 | visualEffectSubview?.alpha = colorTintAlpha 108 | } else { 109 | customBlurEffect.setValue(value, forKeyPath: key) 110 | visualEffectView.effect = customBlurEffect 111 | } 112 | } 113 | 114 | /// Setup views. 115 | private func setupViews() { 116 | addSubview(visualEffectView) 117 | visualEffectView.translatesAutoresizingMaskIntoConstraints = false 118 | NSLayoutConstraint.activate([ 119 | visualEffectView.topAnchor.constraint(equalTo: topAnchor), 120 | visualEffectView.trailingAnchor.constraint(equalTo: trailingAnchor), 121 | visualEffectView.bottomAnchor.constraint(equalTo: bottomAnchor), 122 | visualEffectView.leadingAnchor.constraint(equalTo: leadingAnchor), 123 | ]) 124 | } 125 | 126 | /// Update visualEffectView for ios14+, if we need to change blurRadius 127 | private func updateViews() { 128 | if #available(iOS 14.0, *) { 129 | visualEffectView.removeFromSuperview() 130 | let newEffect = CustomBlurEffect.effect(with: .extraLight) 131 | newEffect.blurRadius = blurRadius 132 | customBlurEffect_ios14 = newEffect 133 | visualEffectView = UIVisualEffectView(effect: customBlurEffect_ios14) 134 | setupViews() 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /Sources/CustomBlurEffectView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | 22 | 23 | -------------------------------------------------------------------------------- /Sources/CustomBlurEffectView/UIVisualEffect+effectSettings.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIVisualEffect+effectSettings.swift 3 | // CustomBlurEffectView 4 | // 5 | // Created by Kononec Dmitrii on 07.09.2020. 6 | // 7 | 8 | import UIKit 9 | 10 | private var AssociatedObjectHandle: UInt8 = 0 11 | 12 | extension UIVisualEffect { 13 | @objc var effectSettings: AnyObject { 14 | get { 15 | return objc_getAssociatedObject(self, &AssociatedObjectHandle) as AnyObject 16 | } 17 | set { 18 | objc_setAssociatedObject(self, &AssociatedObjectHandle, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) 19 | } 20 | } 21 | } 22 | --------------------------------------------------------------------------------