您的位置:首页 > 移动开发

iOS开发有关app启动时的动态页面展示(非启动页面)

2015-09-09 17:14 323 查看
很多APP启动的时候,需要动态的更换启动页面,可以在这个地方增添广告或者是将APP中新加入的一些活动信息等展示给用户。废话不多说,上代码:

一般都是在AppDelegate中的这个方法进行实现,当然这里面的图片可以随意的更改。

- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions

{

self.window.rootViewController = self.viewController;

[self.window makeKeyAndVisible];

//图片扩大淡出的效果开始;

//设置一个图片;这里的图片可以从后台请求,这样我们就可以实现每天弹出不同图片

UIImageView *niceView = [[UIImageView alloc]initWithFrame:CGRectMake(0,0, 320, 480)];

niceView.image = [UIImage imageNamed:@"Default.png"];

//添加到场景

[self.window addSubview:niceView];

//放到最顶层;

[self.window bringSubviewToFront:niceView];

//开始设置动画;

[UIView beginAnimations:nil context:nil];

[UIView setAnimationDuration:2.0];

[UIView setAnimationTransition:UIViewAnimationTransitionNoneforView:self.window cache:YES];

[UIView setAnimationDelegate:self];

//这里还可以设置回调函数;

//[UIViewsetAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];

niceView.alpha = 0.0;

niceView.frame = CGRectMake(-60, -85, 440, 635);

[UIView commitAnimations];

[niceView release];

//结束;

return YES;

}
不得不说苹果还是很贴心的,好多东西都在考虑,我们只需要调用就行

可以参考一下这样的:

- (BOOL)<a target=_blank href="http://www.codes51.com/article/search_Application/" target="_blank" style="color: rgb(0, 0, 0); text-decoration: none;"><strong>Application</strong></a>:(UI<a target=_blank href="http://www.codes51.com/article/search_Application/" target="_blank" style="color: rgb(0, 0, 0); text-decoration: none;"><strong>Application</strong></a> *)<a target=_blank href="http://www.codes51.com/article/search_Application/" target="_blank" style="color: rgb(0, 0, 0); text-decoration: none;"><strong>Application</strong></a> didFinishLaunchingWithOptions:(NS<a target=_blank href="http://www.codes51.com/article/search_Dictionary/" target="_blank" style="color: rgb(0, 0, 0); text-decoration: none;"><strong>Dictionary</strong></a> *)launchOptions
[self.window makeKeyAndVisible];
ADView = [[NSBundle mainBundle ]loadNibNamed:@"LaunchScreen" owner:nil options:nil][0];
ADView.frame = CGRectMake(0, 0, self.window.screen.bounds.size.width, self.window.screen.bounds.size.height);
[self.window addSubview:ADView];
UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH, UISCREEN_HEIGHT)];
NSString *str = @"http://pic.nipic.com/2008-04-01/20084113367207_2.jpg";
[imageV sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"new_feature_1"]];
[ADView addSubview:imageV];
[self.window bringSubviewToFront:ADView];
[NSTimer scheduledTimerWithTimeInterval:15 <span id="4_nwp" style="width: auto; height: auto; float: none;"><a target=_blank id="4_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=18&is_app=0&jk=9a3525226eacaadf&k=target&k0=target&kdi0=0&luki=6&n=10&p=baidu&q=85048100_cpr&rb=0&rs=1&seller_id=1&sid=dfaaac6e2225359a&ssp2=1&stid=0&t=tpclicked3_hc&td=1797308&tu=u1797308&u=http%3A%2F%2Fwww%2Ecodes51%2Ecom%2Farticle%2Fdetail%5F147339%2Ehtml&urlid=0" target="_blank" mpid="4" style="color: rgb(0, 0, 0); text-decoration: none;"><span style="color: rgb(0, 0, 255); width: auto; height: auto;">target</span></a></span>:self selector:@selector(removeADView) userInfo:nil repeats:NO];
#pragma <span id="3_nwp" style="width: auto; height: auto; float: none;"><a target=_blank id="3_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=18&is_app=0&jk=9a3525226eacaadf&k=mark&k0=mark&kdi0=0&luki=5&n=10&p=baidu&q=85048100_cpr&rb=0&rs=1&seller_id=1&sid=dfaaac6e2225359a&ssp2=1&stid=0&t=tpclicked3_hc&td=1797308&tu=u1797308&u=http%3A%2F%2Fwww%2Ecodes51%2Ecom%2Farticle%2Fdetail%5F147339%2Ehtml&urlid=0" target="_blank" mpid="3" style="color: rgb(0, 0, 0); text-decoration: none;"><span style="color: rgb(0, 0, 255); width: auto; height: auto;">mark</span></a></span> - 移除广告View
-(void)removeADView
{
[ADView removeFromSuperview];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息