iOS启动页面多张图片自动切换(带动画效果)
2016-08-15 22:52
555 查看
在AppDelegate.m中首先封装一段利用CATransition设置动画的代码
然后我们在AppDelegate.h中声明一个UIImageView的属性
之后在AppDelegate.m的didFinishLaunchingWithOptions方法中设置图片:
然后就是三个显示图片的方法:
一些动画效果如下:
- (void) transitionWithType:(NSString *) type WithSubtype:(NSString *) subtype ForView : (UIView *) view{ //创建CATransition对象 CATransition *animation = [CATransition animation]; //设置运动时间 animation.duration = 2.0; //设置运动type animation.type = type; if (subtype != nil) { //设置子类 animation.subtype = subtype; } //设置运动速度 animation.timingFunction = UIViewAnimationOptionCurveEaseInOut; [view.layer addAnimation:animation forKey:@"animation"]; }
然后我们在AppDelegate.h中声明一个UIImageView的属性
@property (strong, nonatomic) UIImageView *splashView;
之后在AppDelegate.m的didFinishLaunchingWithOptions方法中设置图片:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [self.window makeKeyAndVisible]; self.splashView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]; [self.splashView setImage:[UIImage imageNamed:@"welcome0"]]; [self.window addSubview:self.splashView]; [self.window bringSubviewToFront:self.splashView]; [self performSelector:@selector(showTheFirstImage) withObject:nil afterDelay:2.0f]; [self performSelector:@selector(showTheSecondImage) withObject:nil afterDelay:5.0f]; [self performSelector:@selector(showTheThirdImage) withObject:nil afterDelay:8.0f]; return YES; }
然后就是三个显示图片的方法:
-(void)showTheFirstImage{ //波纹效果 [self transitionWithType:@"rippleEffect" WithSubtype:kCATransitionFromBottom ForView:self.splashView]; /** 运动方向 kCATransitionFromRight kCATransitionFromLeft kCATransitionFromTop kCATransitionFromBottom */ [self.splashView setImage:[UIImage imageNamed:@"welcome1"]]; } -(void)showTheSecondImage{ //淡化效果 [self transitionWithType:kCATransitionFade WithSubtype:kCATransitionFromBottom ForView:self.splashView]; [self.splashView setImage:[UIImage imageNamed:@"welcome2"]]; } -(void)showTheThirdImage{ //翻页效果 [self transitionWithType:@"pageCurl" WithSubtype:kCATransitionFromBottom ForView:self.splashView]; [self.splashView setImage:[UIImage imageNamed:@"welcome3"]]; }
一些动画效果如下:
//淡化效果 [self transitionWithType:kCATransitionFade WithSubtype:subtypeString ForView:self.view]; //push效果 [self transitionWithType:kCATransitionPush WithSubtype:subtypeString ForView:self.view]; //揭开效果 [self transitionWithType:kCATransitionReveal WithSubtype:subtypeString ForView:self.view]; //覆盖效果 [self transitionWithType:kCATransitionMoveIn WithSubtype:subtypeString ForView:self.view]; //立方体效果 [self transitionWithType:@"cube" WithSubtype:subtypeString ForView:self.view]; //吮吸效果 [self transitionWithType:@"suckEffect" WithSubtype:subtypeString ForView:self.view]; //翻转效果 [self transitionWithType:@"oglFlip" WithSubtype:subtypeString ForView:self.view]; //波纹效果 [self transitionWithType:@"rippleEffect" WithSubtype:subtypeString ForView:self.view]; //翻页效果 [self transitionWithType:@"pageCurl" WithSubtype:subtypeString ForView:self.view]; //反翻页效果 [self transitionWithType:@"pageUnCurl" WithSubtype:subtypeString ForView:self.view]; //相机打开效果 [self transitionWithType:@"cameraIrisHollowOpen" WithSubtype:subtypeString ForView:self.view]; //相机关闭效果 [self transitionWithType:@"cameraIrisHollowClose" WithSubtype:subtypeString ForView:self.view];
相关文章推荐
- iOS动画-来回切换多张图片产生动态效果
- Android之app引导页(背景图片切换加各个页面动画效果)
- app引导页(背景图片切换加各个页面动画效果)
- 惊艳的App引导页:背景图片切换加各个页面动画效果
- app引导页(背景图片切换加各个页面动画效果)
- iOS 视图控制器转场动画/页面切换效果/跳转动画 学习
- android app引导页(背景图片切换加各个页面动画效果)
- app引导页(背景图片切换加各个页面动画效果)
- [Android实例] app引导页(背景图片切换加各个页面动画效果)(申明:来源于网络)
- jquery上下页面视差滚动切换效果|强大的视差响应动画滑动图片切换效果
- app引导页(背景图片切换加各个页面动画效果)
- IOS中多张图片动画效果
- Android之ViewFlipper实现手动+自动切换图片(附加动画效果)
- app引导页(背景图片切换加各个页面动画效果)
- app引导页(背景图片切换加各个页面动画效果)
- AnimWelcome引导页面VS图片切换动画效果
- iOS开发之实现图片自动切换(类似android画廊效果)
- Android app引导页(背景图片切换加各个页面动画效果)
- app引导页(背景图片切换加各个页面动画效果)
- app引导页(背景图片切换加各个页面动画效果)