3 回答
TA贡献1893条经验 获得超10个赞
[ [ UIScreen mainScreen ] bounds ].size.height
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
fabs
if( IS_IPHONE_5 ){}else{}
编辑-更好的检测
IS_WIDESCREEN
:
#define IS_WIDESCREEN ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define IS_IPHONE ( [ [ [ UIDevice currentDevice ] model ] isEqualToString: @"iPhone" ] )#define IS_IPOD ( [ [ [ UIDevice currentDevice ] model ] isEqualToString: @"iPod touch" ] )
IS_IPHONE_5
#define IS_IPHONE_5 ( IS_IPHONE && IS_WIDESCREEN )
重要-iOS 8支持
bounds
UIScreen
nativeBounds
bounds
nativeBounds
nativeBounds
if( [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ] ){ /* Detect using nativeBounds - iOS 8 and greater */}else{ /* Detect using bounds - iOS 7 and lower */}
#define IS_WIDESCREEN_IOS7 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON ) #define IS_WIDESCREEN_IOS8 ( fabs( ( double )[ [ UIScreen mainScreen ] nativeBounds ].size.height - ( double )1136 ) < DBL_EPSILON )#define IS_WIDESCREEN ( ( [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ] ) ? IS_WIDESCREEN_IOS8 : IS_WIDESCREEN_IOS7 )
TA贡献1796条经验 获得超4个赞
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){ CGSize result = [[UIScreen mainScreen] bounds].size; if(result.height == 480) { // iPhone Classic } if(result.height == 568) { // iPhone 5 }}
- 3 回答
- 0 关注
- 482 浏览
添加回答
举报