我不熟悉在 Xcode 中裁剪图像,在我的应用程序中我拍了一张照片,然后将该照片放入圆圈形式的 uiimage 中。我想要做的是在图像处于圆形 View 时放大或移动图像,然后将其保存到最终的 uiimage 中。到目前为止我所拥有的是
CALayer *imageLayer= imageView.layer;
imageView.layer.cornerRadius =imageView.frame.size.height/2;
[imageLayer setBorderWidth:.5];
[imageLayer setMasksToBounds:YES];
[self.view addSubview:imageView];
请尽快帮忙!我很困惑。
最佳答案
以下代码使用缩放参数 scale
从 your_image
的 rect
矩形创建子图像
CGImageRef imageRef = CGImageCreateWithImageInRect([your_image CGImage], rect);
UIImage *subImage = [UIImage imageWithCGImage:imageRef scale:scale orientation:your_image.imageOrientation];
CGImageRelease(imageRef);
关于ios - 如何放大和缩放uiimage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22312451/