我在UIImageView中将图像显示为应用程序的背景图像。这是由getty或shutterstock或其他东西拍摄的专业照片。起初我放了3张照片。它们如下:
320 x 536
640 x 1136
960 x 1704
这导致图像不连贯。因此,我没有将640 x 1136缩放到320 x 568,而是实际购买了尺寸,因此保持了分辨率并降低了噪音。无论我做什么,他们都会不断变得不稳定和质量差。有关为什么会发生这种情况的任何建议?他们应该是很好的品质。
雅虎天气应用程序完美无瑕。高质量的图片。为什么我的应用有这样的问题?
这里是我用来设置背景图片的代码。
PARootViewController - 这是初始化。此类启动所有其他屏幕和身份验证
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kPAPreviousBackgroundImageIndex];
NSInteger randomNumber;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSInteger previousBackgroundIndex = [defaults integerForKey:kPAPreviousBackgroundImageIndex];
do {
randomNumber = [PAProfileObject getRandomNumberBetween:0 to:[self.backgrounds count]];
} while (randomNumber == previousBackgroundIndex);
NSLog(@"Background image at index: %ld\nNumber of backgrounds: %ld",randomNumber,[self.backgrounds count]-1);
[defaults setInteger:randomNumber forKey:kPAPreviousBackgroundImageIndex];
[defaults synchronize];
PABaseViewController - 每个其他视图控制器都继承自此,因此它为每个使用的视图控制器设置背景
self.backgrounds = @[[UIImage imageNamed:@"background-02-i5"],
[UIImage imageNamed:@"racing-the-sun"],
[UIImage imageNamed:@"background-03-i5"],
[UIImage imageNamed:@"background-04-i5"],
[UIImage imageNamed:@"background-05-i5"],
[UIImage imageNamed:@"background-06-i5"],
[UIImage imageNamed:@"background-07-i5"],
[UIImage imageNamed:@"background-08-i5"],
[UIImage imageNamed:@"background-09-i5"],
[UIImage imageNamed:@"background-10-i5"],
[UIImage imageNamed:@"background-11-i5"]];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSInteger backgroundIndex = [defaults integerForKey:kPAPreviousBackgroundImageIndex];
if (backgroundIndex >= [self.backgrounds count])
backgroundIndex = [self.backgrounds count]-1;
self.backgroundImage = [self.backgrounds objectAtIndex:backgroundIndex];
CGRect screen = [[UIScreen mainScreen] bounds];
self.backgroundImageView = [[UIImageView alloc] initWithFrame:screen];
self.backgroundImageView.image = self.backgroundImage;
[self.view insertSubview:self.backgroundImageView belowSubview:self.blurView];
PADashboardViewController - 主屏幕。它顶部有一个按钮,允许用户切换背景以进行测试。现在,我将它设置为后台即时工作
- (IBAction)nextBackgroundPressed:(id)sender {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSInteger currentBackground = [defaults integerForKey:kPAPreviousBackgroundImageIndex];
if (currentBackground < [self.backgrounds count]-1)
currentBackground++;
else
currentBackground = 0;
// self.backgroundImageView.image = [self.backgrounds objectAtIndex:currentBackground];
self.backgroundImageView.image = [UIImage imageNamed:@"background-01-i5"];
[defaults setInteger:currentBackground forKey:kPAPreviousBackgroundImageIndex];
[defaults synchronize];
}
他们是好的形象。高品质,直接来自shutterstock。这不是图像的问题。当我把它放在应用程序中时它只是这样。完全相同图像的并排屏幕截图。一个是应用内,一个是OS X图像查看器。为什么应用程序如此糟糕?