Skip to content
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

Stretchable image regions should default to UIImage cap insets #720

Closed
1ec5 opened this issue Sep 29, 2021 · 3 comments
Closed

Stretchable image regions should default to UIImage cap insets #720

1ec5 opened this issue Sep 29, 2021 · 3 comments
Labels
archived feature 🍏 When working on a new feature or feature enhancement

Comments

@1ec5
Copy link
Contributor

1ec5 commented Sep 29, 2021

#695 added two parameters, stretchX and stretchY, to StyleManager.addImage(_:id:). An iOS developer would find it more intuitive if the method could get the cap insets directly from the UIImage that is already passed in. The expected workflow would be to edit image slicing visually in the asset catalog, load the image by name, and add it to the style without ever specifying the cap insets in code. UIKit frameworks and most third-party frameworks honor these implicitly resizable UIImages the same way. Support for resizable images was originally added to the iOS map SDK in mapbox/mapbox-gl-native-ios#182 (comment), so this is technically a regression.

The stretchX and stretchY parameters should be made optional. When specified, they can override the cap insets in UIImage. The explicit parameters have the benefit of supporting multiple resizable regions, which UIImage doesn’t natively support. However, as it stands, there’s a potential for mismatch if the developer updates the asset catalog but forgets to update the hard-coded stretchX and stretchY arguments. As a workaround, the developer could programmatically convert the cap insets into stretchable regions, but the math is fairly error-prone, so it would be better for the SDK to take care of automatically.

/cc @neelmistry94

@1ec5 1ec5 added the feature 🍏 When working on a new feature or feature enhancement label Sep 29, 2021
@1ec5
Copy link
Contributor Author

1ec5 commented Sep 29, 2021

The stretchX and stretchY parameters should be made optional.

This would be sensible even in the absence of cap inset support, because most style images are unlikely to have stretchable regions.

@macdrevx
Copy link
Contributor

We do plan to support cap insets in a future release. We removed the default params recently to avoid ambiguity when we introduce a new method that works based on cap insets.

@stale stale bot added the archived label Apr 19, 2022
@evil159
Copy link
Contributor

evil159 commented Apr 20, 2022

Fixed in #1269

@evil159 evil159 closed this as completed Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
archived feature 🍏 When working on a new feature or feature enhancement
Projects
None yet
Development

No branches or pull requests

3 participants