IOS开发代码分享之获取启动画面图片的string
程序员文章站
2022-03-02 15:02:16
本代码支持 iphone 6 以下. 支持 iphone 及 ipad
+(nsstring*)getlaunchimagename
{
&nbs...
本代码支持 iphone 6 以下. 支持 iphone 及 ipad
+(nsstring*)getlaunchimagename { nsarray* images= @[@"launchimage.png", @"launchimage@2x.png",@"launchimage-700@2x.png",@"launchimage-568h@2x.png",@"launchimage-700-568h@2x.png",@"launchimage-700-portrait@2x~ipad.png",@"launchimage-portrait@2x~ipad.png",@"launchimage-700-portrait~ipad.png",@"launchimage-portrait~ipad.png",@"launchimage-landscape@2x~ipad.png",@"launchimage-700-landscape@2x~ipad.png",@"launchimage-landscape~ipad.png",@"launchimage-700-landscape~ipad.png"]; uiimage *splashimage; if ([self isdeviceiphone]) { if ([self isdeviceiphone4] && [self isdeviceretina]) { splashimage = [uiimage imagenamed:images[1]]; if (splashimage.size.width!=0) return images[1]; else return images[2]; } else if ([self isdeviceiphone5]) { splashimage = [uiimage imagenamed:images[1]]; if (splashimage.size.width!=0) return images[3]; else return images[4]; } else return images[0]; //non-retina iphone } else if ([[uidevice currentdevice] orientation]==uideviceorientationportrait || [[uidevice currentdevice] orientation] == uideviceorientationportraitupsidedown)//ipad portrait { if ([self isdeviceretina]) { splashimage = [uiimage imagenamed:images[5]]; if (splashimage.size.width!=0) return images[5]; else return images[6]; } else { splashimage = [uiimage imagenamed:images[7]]; if (splashimage.size.width!=0) return images[7]; else return images[8]; } } else { if ([self isdeviceretina]) { splashimage = [uiimage imagenamed:images[9]]; if (splashimage.size.width!=0) return images[9]; else return images[10]; } else { splashimage = [uiimage imagenamed:images[11]]; if (splashimage.size.width!=0) return images[11]; else return images[12]; } } } +(bool)isdeviceiphone { if (ui_user_interface_idiom() == uiuserinterfaceidiomphone) { return true; } return false; } +(bool)isdeviceiphone4 { if ([[uiscreen mainscreen] bounds].size.height==480) return true; return false; } +(bool)isdeviceretina { if ([[uiscreen mainscreen] respondstoselector:@selector(displaylinkwithtarget:selector:)] && ([uiscreen mainscreen].scale == 2.0)) // retina display { return true; } else // non-retina display { return false; } } +(bool)isdeviceiphone5 { if (ui_user_interface_idiom() == uiuserinterfaceidiomphone && [[uiscreen mainscreen] bounds].size.height>480) { return true; } return false; }
上一篇: IOS开发之路--C语言存储方式和作用域
下一篇: IOS开发之路--C语言构造类型