Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set the position of an UIImageView's image?

I have a UIImageView that displays a bigger image. It appears to be centered, but I would like to move that image inside that UIImageView. I looked at the MoveMe sample from Apple, but I couldn't figure out how they do it. It seems that they don't even have an UIImageView for that. Any ideas?

like image 783
Thanks Avatar asked Apr 02 '09 17:04

Thanks


People also ask

Which attribute is used to set an image in ImageView *?

src: src is an attribute used to set a source file or you can say image in your imageview to make your layout attractive.

Can ImageView be clickable?

Using clickable imagesYou can turn any View , such as an ImageView , into a button by adding the android:onClick attribute in the XML layout. The image for the ImageView must already be stored in the drawable folder of your project.


1 Answers

What you need is something like (e.g. showing the 30% by 30% of the top left corner of the original image):

imageView.layer.contentsRect = CGRectMake(0.0, 0.0, 0.3, 0.3);

Description of "contentsRect": The rectangle, in the unit coordinate space, that defines the portion of the layer’s contents that should be used.

like image 189
Golden Thumb Avatar answered Nov 16 '22 00:11

Golden Thumb