I need to stretch an image which looks like as a SMS bubble, but rather than having its arrow on the right/left, it's centered.
I've been tweaking stretchableImageWithLeftCapWidth:topCapHeight: values and also contentStretch of the UIImageView, and corners, stretching works great, but the arrow remains on its original spot i.e. on the final image, the arrow is not centered.
This makes sense, since I'm explicitly defining the stretchable content to just avoid stretching that part so the arrow doesn't look deformed.
Is there any approach to achieve this? It seems like defining UIImage's caps or content stretch rect are not the way to go.
I need to stretch an image which looks like as a SMS bubble, but rather than having its arrow on the right/left, it's centered.
I've been tweaking stretchableImageWithLeftCapWidth:topCapHeight: values and also contentStretch of the UIImageView, and corners, stretching works great, but the arrow remains on its original spot i.e. on the final image, the arrow is not centered.
This makes sense, since I'm explicitly defining the stretchable content to just avoid stretching that part so the arrow doesn't look deformed.
Is there any approach to achieve this? It seems like defining UIImage's caps or content stretch rect are not the way to go.
stretchableImageWithLeftCapWidth:topCapHeight: is limited in what it can do. It expects to have unique edges, and a middle that is generated programmatically by continuing the final pixels from the edges. I don't think there's any way to create a centered speech bubble arrow using just the stretchableImageWithLeftCapWidth:topCapHeight method. How about stacking 2 images, though? Create a stretchable image with no arrow, and then add another image on top of it that is just the arrow? Make the small arrow live in the same space as the stretchable UIImageView, with the struts and springs set up so it stays centered in it's view at a fixed size. You could probably make it a subview of the UIImageView that contains your stretchable image.
I bet you could get that to look perfect with a little fine-tuning.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.