如何放大和缩放uiimage



我刚开始在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];

请尽快帮助!

以下代码从your_imagerect矩形中创建子图像,缩放参数为scale

CGImageRef imageRef = CGImageCreateWithImageInRect([your_image CGImage], rect);
UIImage *subImage = [UIImage imageWithCGImage:imageRef scale:scale orientation:your_image.imageOrientation];
CGImageRelease(imageRef);

最新更新