我很想在Xcode中裁剪图像,在我的应用程序中我拍了一张照片,然后将这张照片放入一个圆圈状的uiimage中。我想要做的是在图像处于圆圈视图中时放大或移动图像,然后将其保存到最终的uiimage。到目前为止我所拥有的是
CALayer *imageLayer= imageView.layer;
imageView.layer.cornerRadius =imageView.frame.size.height/2;
[imageLayer setBorderWidth:.5];
[imageLayer setMasksToBounds:YES];
[self.view addSubview:imageView];
请尽快帮助!我很困惑。
答案 0 :(得分:1)
以下代码使用缩放参数rect
从your_image
scale
矩形创建子图像
CGImageRef imageRef = CGImageCreateWithImageInRect([your_image CGImage], rect);
UIImage *subImage = [UIImage imageWithCGImage:imageRef scale:scale orientation:your_image.imageOrientation];
CGImageRelease(imageRef);