开发者

How to crop 6% off on each side?

开发者 https://www.devze.com 2023-03-13 03:24 出处:网络
I am trying to crop off about 6% of a UIImage. However, it\'s wanting to revert back to a square. Here\'s my code:

I am trying to crop off about 6% of a UIImage. However, it's wanting to revert back to a square. Here's my code:

CGRect newSize = CGRectMake(image.size.width * .06, 0.0, image.size.width * 0.89, image.size.height);
CGImageRef tmp = CGImageCreateWithImageInRect([image CGImage], ne开发者_开发问答wSize);
UIImage *finalImage = [UIImage imageWithCGImage:tmp];
CGImageRelease(tmp);

Please help!


This article is a reference to me when it comes to resizing images in iOS.

Not only he provides a bunch of methods to be used as a category for UIImage, but also explains how to accomplish resizing, cropping, round corners, and more.

0

精彩评论

暂无评论...
验证码 换一张
取 消