App启动界面加载自己想要的图片

7 篇文章 0 订阅
1 篇文章 0 订阅


1、利用系统自带的LanuchSreen,每次启动程序时,都会自动启动自带的LanuchScreen.xib文件;当然,只有在Xcode6之后才有。。。

2、直接看代码:


3、启动程序的画面效果:

4、画面中的图片是百度上的,小清新。。。

5、代码解释:

//重新捕捉window,如果不加此代码,就没有效果了。。。
    [self.window makeKeyAndVisible];
    //将系统的LanuchScreen重新load过来,并且形成一个新的view(phLanuchView)
    self.phLanuchView = [[NSBundle mainBundle ]loadNibNamed:@"LaunchScreen" owner:nil options:nil][0];
    //调节位置
    self.phLanuchView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
    //在window上加上这个view
    [self.window addSubview:self.phLanuchView];
    //将图片add到phLanuchView上
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 50)];
    NSString *str = @"http://img.xiaba.cvimage.cn/4e4f46dce5688376610009d2.jpg";
    //使用SDWebImage加载
    [imageView sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"default"]];
    [self.phLanuchView addSubview:imageView];
    //放到window最前面
    [self.window bringSubviewToFront:self.phLanuchView];
    //不可能一直看图片的,记得用个定时器移除phLanuchView
    [NSTimer scheduledTimerWithTimeInterval:20.0f target:self selector:@selector(removeLanuch) userInfo:nil repeats:NO];
6、额。。。Lanuch写错了,是Launch,算了。。不改了!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值