Skip to content

fix(ios): apply box shadow alpha only once - #12

Merged
farfromrefug merged 1 commit into
mainfrom
fix/ios-box-shadow-double-alpha
Oct 30, 2026
Merged

farfromrefug merged 1 commit into
mainfrom
fix/ios-box-shadow-double-alpha

Conversation

@farfromrefug

Copy link
Copy Markdown

Problem

On iOS, box shadows with an alpha color render much fainter than on Android. In background.ios.ts the outer shadow layer sets both shadowOpacity = color.a / 255 and shadowColor = color.ios.CGColor. The CGColor already carries the alpha and CALayer multiplies the two, so the effective alpha is a² (#00000033 = 0.2 renders as 0.04).

Fix

Keep the alpha in the CGColor and set shadowOpacity = 1. Android applies the alpha once.

The previous color.a ? a/255 : 1 special case for a === 0 is dropped: with alpha 0 the CGColor is fully transparent either way, so the shadow stays invisible (no behaviour change). Colors without alpha info still render at full opacity.

Testing

No unit test: the code path needs native CALayer APIs and the repo's jest specs only cover pure TS. Visual check on iOS still required: boxShadow: 0 4 12 #00000033 before/after.

Follow-up (not in this PR)

packages/core/ui/text-base/index.ios.ts _setShadow (text-shadow) has the same pattern (shadowOpacity = a/255 + shadowColor = CGColor).

Refs: ossappscollective/OSS-DocumentScanner#797

🤖 Generated with Claude Code

CALayer multiplies shadowOpacity with the alpha of shadowColor. The box
shadow code set shadowOpacity to color.a / 255 while also passing a
CGColor already carrying that alpha, so an alpha color rendered with a^2
(e.g. NativeScript#33 showed as 0.04 instead of 0.2). Keep the alpha in the
CGColor and set shadowOpacity to 1, matching Android.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@farfromrefug
farfromrefug marked this pull request as ready for review October 30, 2026 13:44
@farfromrefug
farfromrefug merged commit 1f1b508 into main Oct 30, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant