Geo*_*old 5 iphone uiimageview uiimage
我正在UIImageView创建一个基于磁贴的应用程序.基本上,我正在拍摄单个图像文件并将其分解成碎片,然后将碎片分配给我的tile(UIImageViews),以便可以单独操作它们.
获取图像的一部分并使用它来绘制图像的最佳方法是UIImageView什么?我想过覆盖drawRect和使用CGAffineTransform,但它好像有应该是要做到这一点,也许通过指定一个简单的方法CGRect对UIImage传递给UIImageView,但我没有看到这个的API.
Geo*_*old 11
开始了:
UIImage* img = [UIImage imageNamed:@"myImage.jpg"];
CGRect imgFrame = CGRectMake(x, y, tileWidth, tileHeight);
CGImageRef imageRef = CGImageCreateWithImageInRect([img CGImage], imgFrame);
UIImage* subImage = [UIImage imageWithCGImage: imageRef];
CGImageRelease(imageRef);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2948 次 |
| 最近记录: |