IOS开发代码分享之获取启动画面图片的string
本代码支持iPhone6以下.支持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([selfisDeviceiPhone]) { if([selfisDeviceiPhone4]&&[selfisDeviceRetina]) { splashImage=[UIImageimageNamed:images[1]]; if(splashImage.size.width!=0) returnimages[1]; else returnimages[2]; } elseif([selfisDeviceiPhone5]) { splashImage=[UIImageimageNamed:images[1]]; if(splashImage.size.width!=0) returnimages[3]; else returnimages[4]; } else returnimages[0];//Non-retinaiPhone } elseif([[UIDevicecurrentDevice]orientation]==UIDeviceOrientationPortrait||[[UIDevicecurrentDevice]orientation]==UIDeviceOrientationPortraitUpsideDown)//iPadPortrait { if([selfisDeviceRetina]) { splashImage=[UIImageimageNamed:images[5]]; if(splashImage.size.width!=0) returnimages[5]; else returnimages[6]; } else { splashImage=[UIImageimageNamed:images[7]]; if(splashImage.size.width!=0) returnimages[7]; else returnimages[8]; } } else { if([selfisDeviceRetina]) { splashImage=[UIImageimageNamed:images[9]]; if(splashImage.size.width!=0) returnimages[9]; else returnimages[10]; } else { splashImage=[UIImageimageNamed:images[11]]; if(splashImage.size.width!=0) returnimages[11]; else returnimages[12]; } } } +(BOOL)isDeviceiPhone { if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone) { returnTRUE; } returnFALSE; } +(BOOL)isDeviceiPhone4 { if([[UIScreenmainScreen]bounds].size.height==480) returnTRUE; returnFALSE; } +(BOOL)isDeviceRetina { if([[UIScreenmainScreen]respondsToSelector:@selector(displayLinkWithTarget:selector:)]&& ([UIScreenmainScreen].scale==2.0)) //Retinadisplay { returnTRUE; } else //non-Retinadisplay { returnFALSE; } } +(BOOL)isDeviceiPhone5 { if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone&&[[UIScreenmainScreen]bounds].size.height>480) { returnTRUE; } returnFALSE; }