是否有方法以UIImage的方式获得当前设备的启动映像?或带有图像的UIImageView
发布于 2013-08-18 11:33:59
您只需要获得Default.png,它将在必要时应用任何@2x。
- (UIImage *)splashImage {
return [UIImage imageNamed:@"Default.png"];
}如果您关心的是获得iPhone 5特定的一个,您需要做一个高度检查:
- (UIImage *)splashImage {
if ([[UIScreen mainScreen] bounds].size.height == 568.0){
return [UIImage imageNamed:@"Default-568h.png"];
} else {
return [UIImage imageNamed:name];
}
}发布于 2013-08-18 11:20:16
首先使用[UIDevice currentDevice]和[UIScreen mainScreen]减少启动映像的名称,然后像读取任何其他资源映像一样读取该映像。
[UIImage imageNamed:yourLaunchedImageName];发布于 2014-10-20 12:51:22
你可以写这样的东西。
在这里,我们正在找出什么飞溅图像显示(取决于设备和屏幕旋转),并把它作为一个子视图到我们的窗口。
- (void)showSplashImage
{
NSString *imageSuffix = nil;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
imageSuffix = [[UIScreen mainScreen] bounds].size.height >= 568.0f ? @"-568h@2x" : @"@2x";
}
else
{
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
imageSuffix = UIInterfaceOrientationIsPortrait(orientation) ? @"Portrait" : @"-Landscape";
imageSuffix = [UIScreen mainScreen].scale == 2.0 ? [imageSuffix stringByAppendingString:@"@2x~ipad"] : [imageSuffix stringByAppendingString:@"~ipad"];
}
NSString *launchImageName = [NSString stringWithFormat:@"Default%@.png",imageSuffix];
NSMutableString *path = [[NSMutableString alloc]init];
[path setString:[[NSBundle mainBundle] resourcePath]];
[path setString:[path stringByAppendingPathComponent:launchImageName]];
UIImage * splashImage = [[UIImage alloc] initWithContentsOfFile:path];
UIImageView *imageView = [[UIImageView alloc] initWithImage:splashImage];
imageView.tag = 2;
[self.rootViewController.view addSubview:imageView];
}https://stackoverflow.com/questions/18298477
复制相似问题