I would like to achieve :
UIImageView
so that image
does not meet the edges of the UIImageView
Bottomline: I want to increase the touch area of the UIImageView
without stretching the image beyond certain size.
Is it possible through storyboard ? If not can anyone tell how to do it programmatically ?
I can achieve similar functionality through a UIButton
and setting image inset through storyboard but I can't find any such thing with UIImageView
.
Using the method given here :
UIImage *image= [MyUtil imageWithImage:[UIImage imageNamed:@"MyImage"] scaledToSize:CGSizeMake(80, 80)];
UIImageView* imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
imgView.contentMode = UIViewContentModeCenter;
[imgView setImage:image];
Now your insets become 100-80 i.e. 20 .
This is a workaround to provide insets to an UIImageView. Better answers are welcomed.