When I set a search field background image on a UIImage
, the padding between the magnifying glass and placeholder text in the search bar when selected changes.
With the default background:
With a custom background:
This change is caused by these two lines:
UIImage *colorImage = [UIImage imageWithColor:[UIColor grayColor] size:CGSizeMake(28, 28)];
[self setSearchFieldBackgroundImage:[colorImage imageWithRoundedCorners:5] forState:UIControlStateNormal];
imageWithRoundedCorners:
is a category method that simply draws the image onto a CALayer
with a corner radius and then creates a UIImage
from the graphics context.
Why is this and how can I avoid this? I tried passing an explicitly resizable image, but that had no effect.