Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create a UIImageView that crops an image and displays only 100w 100h at 50x and 200y

I am trying to create a box that pops up in my xcode app that just displays an image of that size. I have the following

UIImageView *newView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"beach.jpg"]]; 

but this creates the full size image and just shows it. How would I only show it as 100w by 100h at 50 over and 200 down? Would I use CGRect?

Also, can I make it so that clicking it causes it to disappear?

edit #1 I don't want to resize down the image - would rather just pull the 100 squared pixels and place them in a frame.

like image 532
timpone Avatar asked Dec 05 '12 02:12

timpone


1 Answers

Please try using the following code.

MyImageview.contentMode = UIViewContentModeScaleAspectFill;  MyImageview.clipsToBounds = YES; 
like image 119
Paramasivan Samuttiram Avatar answered Nov 11 '22 21:11

Paramasivan Samuttiram