[iOS学习]设置iPhone5 5s6背景图
2015-06-02 22:25
387 查看
1. 屏幕大小问题点
随着iOS的碎片化,特别是 4/4s/5/5s/6/6p出来后,每个屏幕的高度宽度都不一样,如果背景图片不具有拉伸平铺的性质,
则同时@2x图的4/4s/5/5s/6 的图片将被压缩或拉伸。
关于iOSLauchImage画面适应iPhone5 iPhone5s iPhone6 iPhone6P分辨率的介绍有很多,比如将LaunchImage设置成
多个分辨率,具体请参照。
2.背景图的设置方法。
一般采用屏幕大小去判断是哪种苹果机型如一下代码:
还有一种方法是通过系统的参数去判断
这个platform的值比较杂乱,其中iphone6 得到的是”iPhone7,2“ 而iphone6P得到的是“iphone7,1”
随着iOS的碎片化,特别是 4/4s/5/5s/6/6p出来后,每个屏幕的高度宽度都不一样,如果背景图片不具有拉伸平铺的性质,
则同时@2x图的4/4s/5/5s/6 的图片将被压缩或拉伸。
关于iOSLauchImage画面适应iPhone5 iPhone5s iPhone6 iPhone6P分辨率的介绍有很多,比如将LaunchImage设置成
多个分辨率,具体请参照。
2.背景图的设置方法。
一般采用屏幕大小去判断是哪种苹果机型如一下代码:
#import "BXDevice.h" @implementation BXDevice +(thisDeviceClass) currentDeviceClass { CGFloat greaterPixelDimension = (CGFloat) fmaxf(((float)[[UIScreen mainScreen]bounds].size.height), ((float)[[UIScreen mainScreen]bounds].size.width)); switch ((NSInteger)greaterPixelDimension) { case 480: return (( [[UIScreen mainScreen]scale] > 1.0) ? thisDeviceClass_iPhoneRetina : thisDeviceClass_iPhone ); break; case 568: return thisDeviceClass_iPhone5; break; case 667: return thisDeviceClass_iPhone6; break; case 736: return thisDeviceClass_iPhone6plus; break; case 1024: return (( [[UIScreen mainScreen]scale] > 1.0) ? thisDeviceClass_iPadRetina : thisDeviceClass_iPad ); break; default: return thisDeviceClass_unknown; break; } } + (NSString *)magicSuffixForDevice { switch ([BXDevice currentDeviceClass]) { case thisDeviceClass_iPhone: return @""; break; case thisDeviceClass_iPhoneRetina: return @"@2x"; break; case thisDeviceClass_iPhone5: return @"-568h@2x"; break; case thisDeviceClass_iPhone6: return @"-667h@2x"; //or some other arbitrary string.. break; case thisDeviceClass_iPhone6plus: return @"-736h@3x"; break; case thisDeviceClass_unknown: default: return @""; break; } } +(UIImage *)imageDeviceWithName:(NSString *)fileName { UIImage *result = nil; NSString *nameWithSuffix = [fileName stringByAppendingString:[BXDevice magicSuffixForDevice]]; result = [UIImage imageNamed:nameWithSuffix]; if (!result) { result = [UIImage imageNamed:fileName]; } return result; } @end
还有一种方法是通过系统的参数去判断
struct utsname systemInfo; uname(&systemInfo); NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
这个platform的值比较杂乱,其中iphone6 得到的是”iPhone7,2“ 而iphone6P得到的是“iphone7,1”
相关文章推荐
- 使用iostat分析IO性能
- iOS开发的一些奇巧淫技...
- github优秀开源项目大全-iOS
- IOS判断当前日期在两个日期之间。
- iOS中NSRunLoop的模式
- ios 安卓锁屏
- iOS中Blocks的介绍
- IOS 给图片添加水印 打印文字
- iOS symbol化的多种方式
- netbios wins dns LLMNR
- 构建iOS持续集成平台(一)——自动化构建和依赖管理
- IOS开发学习笔记037-九宫格代码实现
- IOS行货自动打包
- IOS添加pch文件
- Xcode6.3模拟器ios8.3模拟器不能弹出虚拟键盘及虚拟键盘无法切换中文输入的解决办法
- 解决XCode6在IOS8系统上出现部分黑屏与不适配问题
- iOS点击空白区域隐藏键盘
- iOS CACoreAnimation :CAKeyframeAnimation
- iOS查看和清理缓存
- [iOS] 如何将你的程序打包成ipa