0
我想设置一个视图的背景图像。我使用三个图像:backgroundimage.png(尺寸320 x 480),[email protected](尺寸640 x 960)和[email protected](尺寸640 x 1136)为Iphone 3g,Iphone 4s和Iphone 5设置背景图像
适用于iphone 3g尺寸。但是当我测试视网膜大小时,背景图像只是原始图像的一小部分。我认为,我必须以某种方式缩小图像的尺寸,或为其设置框架,但我不知道如何。
感谢所有帮助;)
多数民众赞成代码:
self.view.backgroundColor = [UIColor clearColor];
UIImage *backgroundImage = [[UIImage alloc]init];
if ([[UIScreen mainScreen] bounds].size.height == 568) {
backgroundImage = [UIImage imageNamed:@"[email protected]"];
}
else{
backgroundImage = [UIImage imageNamed:@"background"];
}
self.view.backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
非常感谢。有用。 –
@PeterK如果答案有帮助,请点击帖子旁边的“复选标记”,将其标记为正确。 –