I am trying to create a resizable version of the following image (40x28, the small triangle at the bottom should be centered horizontally):
UIEdgeInsets imageInsets = UIEdgeInsetsMake(4.0f, 4.0f, 8.0f, 4.0f);
UIImage *pinImage = [[UIImage imageNamed:@"map_pin"] resizableImageWithCapInsets:imageInsets];
As per the documentation, this simple approach won't work since my triangle falls into resizable area (fixed height but scalable width):
This will cause the same problem as described in this very similar SO post - duplicated (tiled) triangles. But unfortunately their solution doesn't work for my particular case since excluding the triangle from scalable area causes its misplacement and it won't be centered horizontally due to obvious reasons.
So I wonder... is it possible to achieve my goal using the [UIImage resizableImageWithCapInsets:]
method at all? Or may be I should try something else like drawing everything in the code instead?
Basically, I would like to implement something like Info Windows from Google Maps SDK: