New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ios): shadow issue fixed #12005
fix(ios): shadow issue fixed #12005
Conversation
Tests:
|
Needs to be rebased now that the cornerRadius fix has landed. Also, we likely want some UI tests to verify the look with a shadow and cornerRadius. |
This seems very complicated to me. Are we sure we need to mess around with additional layers just to achieve this? There must be a simpler way... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After going deep down the rabbit hole, it appears it is not easier.
See:
- https://blog.prototypr.io/what-should-you-know-about-shadows-691aa930ce02
- https://medium.com/swifty-tim/views-with-rounded-corners-and-shadows-c3adc0085182
But I do think we could benefit greatly from explicitly defining a root layer that we attach the clip/content/shadow layers to as sublayers - then I think it may also properly animate them together. The first link shows some code where they're explicitly making the UIView.layer
the rootLayer
and then adding shadowLayer
as sublayer, then a contentLayer
as sublayer of the shadow - and apply the same clipping path as the mask for the content and the path of the shadow.
So:
-- rootLayer (UIView.layer)
|-- shadowLayer
|-- contentLayer (mask is the same as parent's path, defined by the cornerRadius path stuff)
The second link sort of sneakily "copies" the contents into a sublayer if we have a shadow and cornerRadius. (so in effect, it converts a single layer to a a rootLayer with shadow properties and sublayer with the contents and the cornerRadius w/mask) I think it relies on the fact that a shadow is supposed to automatically look at sublayers to determine it's path/look.
So the concept of introducing a shadow layer as you do here makes sense, but I do think your changes place it outside the view's layers (basically it appears to stick it in the view's parent as a sibling of the view). I think that's the incorrect approach and likely why the shadow would get disconnected when we do animations.
Obviously multiple-value borderRadius has made this a giant pain in the butt compared to single value (since iOS has a nice cornerRadius property for that case).
Looking at our code, for a multi-radius value view likely need a layer hierarchy like this:
root layer (UIView.layer, masksToBounds = NO)
`-- shadowLayer (set shadow properties, fill color clear, path set to the borderRadius bezier path)
`-- contentLayer (actual contents, mask set to the borderRadius bezier path)
|-- borderLayer (for drawing custom border when radius is multi-value)
|-- backgroundLayer (for background images)
|-- gradientLayer (for gradients)
(Note I'm unclear on if it would make more sense to make those child of the content layer get nested rather than all be siblings?)
For no radius, single radius value, or case where we can use CACornerMask
(only some corners get radius but must be same value) we should be able to simplify and use the cornerRadius property and not need the shadowLayer
or borderLayer
.
we will open a new ticket to track edge case of animations with view having shadow and custom borderRadius with more than single value
OK, we discussed on call - @vijaysingh-axway will open a new ticket for the specific edge case of animating a view that has a shadow and |
FR Passed. There is an issue with animation of view having multiple border radius. This would be handled as a separate ticket https://jira.appcelerator.org/browse/TIMOB-28115. Verified on: |
use cornerradius property of view’s layer if one border radius is set on all corners Fixes TIMOB-28103, TIMOB-28110
5da8866
to
559429b
Compare
The backport to
Check the run for full details # Fetch latest updates from GitHub
git fetch
# Check out the target branch
git checkout 9_3_X
# Make sure it's up to date
git pull
# Check out your branch
git checkout -b backport-12005-to-9_3_X
# Apply the commits from the PR
curl -s https://github.com/appcelerator/titanium_mobile/commit/b1d6d7cc99c02148f810128e6f4258e99b311e1a.patch | git am -3 --ignore-whitespace
curl -s https://github.com/appcelerator/titanium_mobile/commit/467a91685d86e1e0cc45205d5ae37f6f84d0cf51.patch | git am -3 --ignore-whitespace
curl -s https://github.com/appcelerator/titanium_mobile/commit/559429ba770894cd5a16d0e91e7e829aac51b1aa.patch | git am -3 --ignore-whitespace
# Push it to GitHub
git push --set-upstream origin backport-12005-to-9_3_X Then, create a pull request where the |
manually cherry-picked to 9_3_X |
https://jira.appcelerator.org/browse/TIMOB-28103
https://jira.appcelerator.org/browse/TIMOB-28110
Note-