1

我正在从图像选择器中选择图像,然后我想将该图像的比例更改为 facebook 封面。我有一张图片,假设它的分辨率为 640 宽和 480 高,我想将其更改为 facebook 封面(851 像素宽和 315 像素高)我将如何在 iphone 中以编程方式执行此操作 检查此链接以获取封面图片详细信息 谢谢。

4

1 回答 1

1
 Use this Method to Resize the image according to the given content mode, taking into account the image's orientation...

- (UIImage *)resizedImageWithContentMode:(UIViewContentMode)contentMode bounds:(CGSize)bounds
                interpolationQuality:(CGInterpolationQuality)quality {

CGFloat horizontalRatio = bounds.width / self.size.width;
CGFloat verticalRatio = bounds.height / self.size.height;
CGFloat ratio;

switch (contentMode) {
    case UIViewContentModeScaleAspectFill:
        ratio = MAX(horizontalRatio, verticalRatio);
        break;

    case UIViewContentModeScaleAspectFit:
        ratio = MIN(horizontalRatio, verticalRatio);
        break;

    default:
        [NSException raise:NSInvalidArgumentException format:@"Unsupported content mode:  %d", contentMode];
}

CGSize newSize = CGSizeMake(self.size.width * ratio, self.size.height * ratio);

return [self resizedImage:newSize interpolationQuality:quality];

}

并转到此链接以获取更多详细信息,以正确的方式调整 Uiimage 大小

于 2012-12-03T05:12:09.523 回答