我只想在UIImageView中显示一部分图像,而不是整个图像。我该怎么做?
您可以尝试裁剪原始图像:
UIImage *myImage = [UIImage imageWithContentsOfFile:"my_image.png"]
CGRect *rect = CGRectMake(0, 0, 64, 64);
CGImageRef imageRef = CGImageCreateWithImageInRect([myImage CGImage], rect);
UIImage *topLeftImage = [UIImage imageWithCGImage:imageRef]];
CGImageRelease(imageRef);
,或者如果您希望用户能够将图像铺好,则可以将图像添加到UIScrollView
。