Ios splash设计

作者QQ:415074476

QQ群:191280586

Ios  splash设计

一.最简单的是放一个default.png

也可以在plist 中指定一个文件名.

Key为Launch image(iPhone)和Launch image(iPad)

 

二.动画实现.

又分为两种.

一种是UIView层面的,

一种是使用CATransition进行更低层次的控制

 

UIView代码示例:

[code]

[UIView beginAnimations:@”Curl”context:nil];//动画开始

[UIView setAnimationDuration:0.75];

[UIView setAnimationDelegate:self];

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:myview cache:YES]; //动画转化在这里定义,关键字CurlUp

[myview removeFromSuperview];

[UIView commitAnimations];

[/code]

 

 

CATransition 代码示例:

[code]

CATransition *animation = [CATransition animation];

[animation setDuration:1.25f];

[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];

[animation setType:kCATransitionReveal]; //动作定义

[animation setSubtype: kCATransitionFromBottom];//方向定义

[self.view.layer addAnimation:animation forKey:@”Reveal”];

[/code]

这里使用了setType与setSubtype组合,这使用个比较保险,因为他的参数就是官方API里定义的,他们的参数说明可以参考如下:

 

[animation setType:@”suckEffect”];

这里的suckEffect就是效果名称,可以用的效果主要有:

pageCurl 向上翻一页

pageUnCurl 向下翻一页

rippleEffect 滴水效果

suckEffect 收缩效果,如一块布被抽走

cube 立方体效果

oglFlip 上下翻转效果

 

除了以上效果.还可以自定义效果.

 

 

CGAffineTransformMakeRotation();//旋转

CGAffineTransformMakeScale();//缩放

CGAffineTransformMakeTranslation ();//位移

CGAffineTransformMake(CGFloat a,

CGFloat b,

CGFloat c,

CGFloat d,

CGFloat tx,

CGFloat ty);//自定义变换.自己提供坐标系转换参数

设原坐标点为(x,y);

新坐标点为(x1,y1);

则有下面的对应关系:

x1 = ax+cy+dx;

y1 = bx+dy+dy;

 

问题:如何把动画应用到splash中.

 

第一种:在loadView中实现.

分两层,1是splash图片,一个是主场景.

先把主场景隐藏起来.

两个动画:

1.动画过程1把splash图片隐藏掉.即alpha=0.0

在setAnimationDidStopSelector指定新动画过程2

CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@”opacity”];
[scaleAnimation setDuration:0.3];
[scaleAnimation setFromValue: [NSNumber numberWithDouble:0.0]];
[scaleAnimation setToValue: [NSNumber numberWithDouble:1.0]];
[scaleAnimation setFillMode:kCAFillModeForwards];
[scaleAnimation setRemovedOnCompletion:NO];
[iCityItem.btnDelete.layer addAnimation:scaleAnimation forKey:@”opacity”];

[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:0.05] forKey:kCATransactionAnimationDuration];
[CATransaction setValue:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn] forKey:kCATransactionAnimationTimingFunction];
[CATransaction setCompletionBlock:^{
[self performSelector:@selector(fadout)];
}];
middleLayer.transform = [self getTransformSkew:70];
topLayer.transform = [self getTransformSkew:85];
middleLayer.opacity=0.1;
topLayer.opacity=0.1;

[CATransaction commit];

2.动画过程2把主场景展示出来

 

第二种:在application:didFinishLaunchingWithOptions方法中实现.

1.加载splash图片

2. 延迟加载主过程

3.在主过程中调用动画..

关键在于延迟调用

[self performSelector:@selector(loadMain) withObject:nil afterDelay:0.1f];