Nikos
Nikos

Reputation: 787

resizableImageWithCapInsets images always misaligned?

Is it possible to create a properly aligned UIImageView that has a resizable image?

I tried everything (e.g. images power of two, etc) and cannot make it work.

The coordinates of the UIImageView are:

po _Background

(UIImageView *) $1 = 0x14c42bd0 
<UIImageView: 0x14c42bd0;
frame = (16 38; 992 672);
opaque = NO;
autoresize = LM+RM+TM+BM;
userInteractionEnabled = NO;
layer = <CALayer: 0x14c42ba0>> - (null)

The UIImage itself is 96x96 (retina, i.e. png is 192x192 with a scale of 2). The resizable UIImage is created using:

UIEdgeInsets edgeInsets = UIEdgeInsetsMake(32, 32, 32, 32);
UIImage* resizableImage = [originalImage resizableImageWithCapInsets:edgeInsets];
[_Background setImage:resizableImage];

When turning on 'Color misaligned images' in the simulator the UIImageView _Background is highlighted with yellow. Removing its UIImage in the debugger:

[_Background setImage:nil];

removes the yellow highlight, i.e. no image -> no mis-alignment.

Anyone knows what is going on and how I can make sure it aligns?

thanks.

Upvotes: 0

Views: 531

Answers (1)

Jesse Rusak
Jesse Rusak

Reputation: 57168

According to this answer: What does yellow tinting represent when using "color misaligned images" on iPhone/iOS, the yellow highlight indicates the image is stretched. Since that's what you're asking for with the resizable image, it makes sense that it's always the case.

Upvotes: 5

Related Questions