A subclass of UIVisualEffectView
that lets you set a custom blur radius + intensity, or set CALayer.filter
using CAFilter
(which is obfuscated since it's private API).
Animation is supported for changing the blur radius (or blur percent intensity) for a given UIBlurEffect.Style
, and also for custom effects via CAFilter
(please see gif below for demo).
- Support for animatable
CAColorMatrix
(i.e.colorMatrix
filter). configurable viaColorTransform
orColorMatrixRGBA
. - Support for
variableBlur
, w/ animatable blur radius. - Other animatable filters:
colorMonochrome
,colorSaturate
,colorBrightness
,colorContrast
,colorHueRotate
,compressLuminance
,gaussianBlur
,luminanceCurveMap
,vibrantDark
,vibrantLight
, etc (seeLayerFilterType
for full list of filters).
Experiment02ViewController.swift
VisualEffectBlurTestViewController.swift
VisualEffectViewExperiment01ViewController.swift
RNIVisualEffectCustomFilterViewTest01Screen.tsx
Experiment01ViewController.swift
VisualEffectCustomFilterViewTest02Controller.swift
VisualEffectCustomFilterViewTest02Screen.tsx
very special thanks to: junzhengca, brentvatne, expo, EvanBacon, corasan, lauridskern, ronintechnologies, gerzonc, and edencakir for becoming a monthly sponsor, and thank you fobos531 for being a one time sponsor š„ŗ (if you have the means to do so, please considering sponsoring here)
This little library powers react-native-ios-visual-effect-view
under the hood āØ
VisualEffectBlurView
is available through CocoaPods. To install it, simply add the following line to your Podfile
:
pod 'VisualEffectBlurView'
Method #1: Via Xcode GUI:
- File > Swift Packages > Add Package Dependency
- Add
https://github.com/dominicstop/VisualEffectBlurView.git
Method #2: Via Package.swift
:
- Open your project's
Package.swift
file. - Update
dependencies
inPackage.swift
, and add the following:
dependencies: [
.package(url: "https://github.com/dominicstop/VisualEffectBlurView.git",
.upToNextMajor(from: "1.0.0"))
]
// ⨠Code omitted for brevity
import UIKit
import VisualEffectBlurView;
class BasicUsage01: UIViewController {
override func viewDidLoad() {
let blurView = VisualEffectBlurView(blurEffectStyle: .dark);
blurView.blurRadius = 15;
blurView.translatesAutoresizingMaskIntoConstraints = false;
self.view.addSubview(blurView);
NSLayoutConstraint.activate([
blurView.topAnchor.constraint(
equalTo: self.view.topAnchor
),
blurView.bottomAnchor.constraint(
equalTo: self.view.bottomAnchor
),
blurView.leadingAnchor.constraint(
equalTo: self.view.leadingAnchor
),
blurView.trailingAnchor.constraint(
equalTo: self.view.trailingAnchor
),
]);
};
};
import SwiftUI
import VisualEffectBlurView
struct SwiftUIBasicUsage01: View {
var body: some View {
Text("š¼ļø\nš\nš")
.font(.system(size: 128))
.frame(
maxWidth: .infinity,
maxHeight: .infinity
)
.overlay(self.overlay, alignment: .center)
}
var overlay: some View {
VisualEffectBlur(
blurEffectStyle: .constant(.regular),
blurRadius: .constant(nil)
)
};
}
The documentation for this library is currently not available. In the meantime, please browse through the views, and examples directory (or look through the impl. of RN wrapper for this library).
- š¤ Twitter/X:
@GoDominic
- š Email:
dominicgo@dominicgo.dev
- š Website: dominicgo.dev