Repository navigation
Fix low-quality masks on iOS - #1658
Conversation
|
Do you plan a new release soon? I have great hopes that this PR could solve many issues in my app 🙏🏻 |
| CGSize boundsSize = bounds.size; | ||
| CGFloat height = boundsSize.height; | ||
| CGFloat width = boundsSize.width; | ||
| CGFloat scale = [[UIScreen mainScreen] scale]; |
There was a problem hiding this comment.
Since we want to support macOS, you should not use UIScreen, but rather add the option for both platforms analogous to how it is done e.g. with UIColor, so just add new define #define RNSVGScreen UIScreen here: https://github.com/react-native-svg/react-native-svg/blob/39c8332f4dac8acfe1c60338ad4a8f8231538c91/apple/RNSVGUIKit.h#L12 and #define RNSVGScreen NSScreen here: https://github.com/react-native-svg/react-native-svg/blob/39c8332f4dac8acfe1c60338ad4a8f8231538c91/apple/RNSVGUIKit.h#L20 and then use RNSVGScreen instead of UIScreen in your PR.
|
Thanks for the feedback @WoLewicki ! I took it into account but I had to use a different approach as the |
Summary
This PR fixes low-quality masks on iOS, as reported in #1098.
This was caused by the bitmap for the mask being created with CGBitmapContextCreate() which does not take into account the device's pixel-density, unlike UIGraphicsBeginImageContextWithOptions().
To fix it, the pixel-density is retrieved using
[[UIScreen mainScreen] scale]and it is used as a scale factor for the mask bitmap.Test Plan
I've tested using this sample:
Results: