在应用程序中,用户拍照,然后将照片分配给一个按钮,他们可以点击该按钮重新拍摄照片。我无法让它为视网膜图像工作。
这是代码:
BodyData *lastPerson = (BodyData*)[ReadPerson readLastEntry];
CGRect frame = self.frontImage.frame;
CGSize doubleSize = CGSizeMake(self.frontImage.frame.size.width * 2, self.frontImage.frame.size.height * 2);
NSLog(@"frame is: %@", NSStringFromCGRect(self.frontImage.frame));
UIImage *frontPhoto = [[UIImage imageWithData:[lastPerson readPhotoOfSize:Full withAngle:Front withPlaceholderIfNoImage:NO]] resizeTo: doubleSize]; // Custom category to resize image
if (frontPhoto) {
[[self.frontImage imageView] setContentMode: UIViewContentModeScaleAspectFit];
[self.frontImage setImage:frontPhoto forState:UIControlStateNormal];
[self.frontImage setImage:[frontPhoto darkenedImage] forState:UIControlStateHighlighted];
[self.frontImage setFrame:frame];
[self.frontImage.imageView setFrame:frame];
NSLog(@"frontimage sized to: %@", NSStringFromCGSize(self.frontImage.frame.size));
}
日志输出为:
frame is: {{20, 145}, {129, 172}}
frontimage sized to: {258, 344}
自动布局已启用,但图像不会在 viewdidload 时更改,而是在照片已拍摄的通知中更改。
如何获得视网膜质量图像作为按钮的值?我已经添加了所有框架调整大小的东西,因为按钮正在调整大小并且我试图覆盖它,但即使这样也不起作用。
所以按钮应该是:{129, 172},带有@2x 版本的照片。但它是 {258, 344},带有 @1x 版本的照片。