21
如何在Swift中调整图片大小?
我正在使用Swift和Parse.com为iOS开发应用程序 我试图让用户从图像选择器中选择一张图片,然后将所选图像的大小调整为200x200像素,然后再上传到我的后端。 Parse.com有一个用于Instagram复制应用程序的教程,名为“ AnyPic”,其中提供了用于调整图像大小的代码,但这是在Objective-C中。 // Resize the image to be square (what is shown in the preview) UIImage *resizedImage = [anImage resizedImageWithContentMode:UIViewContentModeScaleAspectFit bounds:CGSizeMake(560.0f, 560.0f) interpolationQuality:kCGInterpolationHigh]; // Create a thumbnail and add a corner radius for use in table views UIImage *thumbnailImage = [anImage thumbnailImage:86.0f transparentBorder:0.0f cornerRadius:10.0f interpolationQuality:kCGInterpolationDefault]; 如何在Swift中为所选图片创建200x200px版本(然后上传)? 而且,thumbnailImage函数在做什么?