|
我的例子:
NSURL *url = [NSURL URLWithString:aid];
UIImage *myimage = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
// 首先,獲取想要顯示的部分的大小及位置
CGRect rect = CGRectMake(0, 50, 320, 120);
// 然後,將此部分從圖片中剪切出來
CGImageRef imageRef=CGImageCreateWithImageInRect([myimage CGImage],rect);
UIImage *image1=[UIImage imageWithCGImage:imageRef];
// 最後,將剪切下來圖片放入UIImageView中
[imgView setImage:image1];