Luk*_*vin 12 objective-c uiimageview uiimage ios6 iphone-5
我的一些应用程序使用自定义图像作为背景.检查屏幕尺寸以放置正确图像的正确方法是什么?
在viewDidLoad中是否应该是这样的:
if ([UIScreen mainScreen] == 2.0)
{
UIImage * backgroundImage = [UIImage imageNamed:@"bgimage-568h@2x.png"];
backgroundImageView = [[UIImageView alloc] initWithImage:backgroundImage]];
}
else
{
UIImage * backgroundImage = [UIImage imageNamed:@"bgimage.png"];
backgroundImageView = [[UIImageView alloc] iniWithImage:backgroundImage]];
}
Run Code Online (Sandbox Code Playgroud)
任何提示/建议非常感谢!
谢谢!
Bry*_*yan 16
以下代码检查屏幕的大小/范围.如果屏幕是586点(请记住,屏幕是由于Retina测量的),我们知道这是新的4英寸Retina显示屏.
if ([[UIScreen mainScreen] bounds].size.height == 568)
{
UIImage * backgroundImage = [UIImage imageNamed:@"bgimage-568h@2x.png"];
backgroundImageView = [[UIImageView alloc] initWithImage:backgroundImage];
}
else
{
UIImage * backgroundImage = [UIImage imageNamed:@"bgimage.png"];
backgroundImageView = [[UIImageView alloc] initWithImage:backgroundImage];
}
Run Code Online (Sandbox Code Playgroud)
另请参阅iOS 6应用程序 - 如何处理iPhone 5屏幕尺寸?
| 归档时间: |
|
| 查看次数: |
8443 次 |
| 最近记录: |