小编Jim*_*mmy的帖子

切换背景图像iphone5 - iphone4

在我的FirstViewController我,如果设备是iPhone4的或iPhone5的写开关背景下面的代码:

文件名:bg-for5-568@2x.png
bg-for4@2x.png
bg-for4.png

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIImage *backgroundImage = [[UIImage alloc] init];
    if([[UIScreen mainScreen]bounds].size.height == 568)
    {
       backgroundImage = [UIImage imageNamed:@"bg-for5-568h"];
    }
    else
   {
       backgroundImage = [UIImage imageNamed:@"bg-for4"];
   }
   self.view.backgroundColor = [[[UIColor alloc] initWithPatternImage:backgroundImage] autorelease];
   [backgroundImage release];
}
Run Code Online (Sandbox Code Playgroud)

当我在我的模拟器上隐藏应用程序时,iphone5的背景显示双倍大小,在视图之外.

/*谢谢你*/

iphone cocoa-touch objective-c ios

7
推荐指数
1
解决办法
3512
查看次数

标签 统计

cocoa-touch ×1

ios ×1

iphone ×1

objective-c ×1