簡體   English   中英

如何放大和縮放uiimage

[英]How to zoom in and scale 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];

請盡快幫助! 我很混亂。

下面的代碼創建從子圖像rect的矩形your_image與縮放參數scale

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM