Skip to content

Commit a1f21c2

Browse files
committed
fix(ios): correct vibrancy effect animation and add iOS bundle identifier
1 parent 3da8a26 commit a1f21c2

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

example/app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"scheme": "exampleapp",
99
"userInterfaceStyle": "automatic",
1010
"ios": {
11-
"icon": "./assets/expo.icon"
11+
"icon": "./assets/expo.icon",
12+
"bundleIdentifier": "com.sbaiahmed1.reactnativeblurexampleapp"
1213
},
1314
"android": {
1415
"adaptiveIcon": {

example/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"start": "expo start",
88
"android": "expo run:android",
9+
"prebuild:ios": "expo prebuild --platform ios --clean",
910
"ios": "expo run:ios",
1011
"web": "expo start --web",
1112
"lint": "expo lint",
@@ -47,4 +48,4 @@
4748
"react-native-monorepo-config": "*",
4849
"typescript": "~5.9.2"
4950
}
50-
}
51+
}

ios/Views/VibrancyEffectView.swift

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,24 @@ import UIKit
6868
let blurEffect = UIBlurEffect(style: style)
6969
let vibrancyEffect = UIVibrancyEffect(blurEffect: blurEffect)
7070

71-
// Use animator to control blur intensity
72-
blurAnimator = UIViewPropertyAnimator(duration: 1, curve: .linear)
73-
blurAnimator?.addAnimations { [weak self] in
74-
self?.blurEffectView.effect = blurEffect
75-
self?.vibrancyEffectView.effect = vibrancyEffect
71+
// Set effects directly first to ensure they are visible
72+
// Animating them from nil often causes issues with UIVibrancyEffect
73+
blurEffectView.effect = blurEffect
74+
vibrancyEffectView.effect = vibrancyEffect
75+
76+
// Create animator to adjust intensity
77+
blurAnimator = UIViewPropertyAnimator(duration: 1, curve: .linear) { [weak self] in
78+
self?.blurEffectView.effect = nil
79+
self?.vibrancyEffectView.effect = nil
7680
}
7781

7882
// Convert blurAmount (0-100) to intensity (0.0-1.0)
83+
// We reverse the logic:
84+
// fractionComplete = 0.0 -> effects are fully applied (start state)
85+
// fractionComplete = 1.0 -> effects are removed (end state)
86+
// So to get desired intensity X, we set fractionComplete to (1 - X)
7987
let intensity = min(max(blurAmount / 100.0, 0.0), 1.0)
80-
blurAnimator?.fractionComplete = intensity
88+
blurAnimator?.fractionComplete = 1.0 - intensity
8189

8290
// Stop the animation at the current state
8391
DispatchQueue.main.async { [weak self, weak blurAnimator] in

0 commit comments

Comments
 (0)