软件的启动动画效果

作者: 梦醒繁华 | 来源:发表于2016-07-29 20:21 被阅读501次
  • 效果图
12.gif ed.gif
  • 原理
    先创建一个UIViewController并且将根视图控制器给它,再将图片按顺序加入控制器的视图中,并把图片视图的透明度设置为0,还要把所有视图依次加入一个图片数组中,然后设置一个定时器,按顺序把图片的透明度调为1,当最后一个图片显示时,结束定时器,并把根视图交给主界面

  • 代码

#import "LauchViewController.h"
#import "Common.h"
#import "MainTabBarController.h"
@interface LauchViewController ()
{

    NSMutableArray *imageViews;//图片数组
    int count;//计数count
    
}
@end

@implementation LauchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    count = 0;
    
    self.view.backgroundColor = [UIColor orangeColor];
    [self _createBackImageView];
    
    [self _createImageViews];
    
    //2 定时器的调用
    [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(startAnimation:) userInfo:nil repeats:YES];
    
}
//创建背景图片
-(void)_createBackImageView{

    UIImageView *backImageV = [[UIImageView alloc]initWithFrame:self.view.bounds];
    backImageV.image = [UIImage imageNamed:@"Default"];
    
    [self.view addSubview:backImageV];
}

//定时器调用的方法
-(void)startAnimation:(NSTimer*)timer{

    if (count == imageViews.count) {
        
        //定时器停止
        [timer invalidate];
        
        //显示主界面
        UIStoryboard *storyB = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        
        MainTabBarController *maintabBarC =[storyB instantiateInitialViewController];
        
        self.view.window.rootViewController = maintabBarC;
        
    }else{
    
        [UIView animateWithDuration:0.1 animations:^{
            
            UIImageView *imageV = imageViews[count];
            imageV.alpha = 1;
        }];
        
       
    }
  
    count++;
    
}
//创建图片视图
-(void)_createImageViews{
    
    //创建图片数组
    imageViews = [NSMutableArray array];
    
    CGFloat width = KScreenWidth/4;
    CGFloat height= KScreenHeight/6;
    
    CGFloat x = 0;
    CGFloat y = 0;
    
    //循环创建24张图片视图
    for (int i = 0; i<24; i++) {
        
        NSString *imageName = [NSString stringWithFormat:@"%d.png",i+1];
        UIImage *image = [UIImage imageNamed:imageName];
        
        UIImageView *imageView = [[UIImageView alloc]initWithImage:image];
        
        imageView.alpha = 0;
        
        imageView.frame =CGRectMake(0, 0, width, height);
        
        if (i<4) {//前四张
            
            x = i*width;
            y = 0;
            
        }else if (i<8){//最右边的四张
            
            x =3*width;
            y =height*(i-3);
            
        }else if (i<12){//最下面的四张
            
            //x =KScreenWidth-width*1;
            x =KScreenWidth-width*(i-7);
            y = KScreenHeight-height;
            
        }else if (i<16){//最左边的四张
            
            x = 0;
            y = KScreenHeight-height*(i-10);
            
 
        }else if (i<18){//上边2个
        
            x = width*(i-15);
            y =height;
            
        }else if (i<20){//右边2个
        
            x = width*2;
            y = height*(i-16);
            
        }else if (i<22){//下面2个
        
            x = KScreenWidth-width*(i-18);
            y = KScreenHeight-height*2;
            
            
        }else if (i<24){//最后2个
        
            x = width;
            y = KScreenHeight-height*(i-19);
            
        }
        imageView.origin = CGPointMake(x, y);
        
        //按照顺序将图片放在图片数组中
        [imageViews addObject:imageView];
        
        [self.view addSubview:imageView];

    }
    
    
}

相关文章

  • 软件的启动动画效果

    效果图 原理先创建一个UIViewController并且将根视图控制器给它,再将图片按顺序加入控制器的视图中,并...

  • 制作lottie动画并应用到android项目

    效果图: 这是一个启动页的lottie动画效果,有一些丑,自己做的动画将就看吧。 AE动画制作 工具准备 动画效果...

  • 【基础界面】A.启动画面(Beta)

    【基础界面】A.启动画面(Beta) 什么是启动画面? 启动应用程序后,进入主功能界面前会有一张图片或一段动画效果...

  • iOS 自定义转场动画

    本文记录分享下自定义转场动画的实现方法,具体到动画效果:新浪微博图集浏览转场效果、手势过渡动画、网易音乐启动屏转场...

  • iOS动画(四) --自定义转场动画

    本文记录分享下自定义转场动画的实现方法,具体到动画效果:新浪微博图集浏览转场效果、手势过渡动画、网易音乐启动屏转场...

  • 类似列表的view伸缩动画

    1,写出所要实现的动画效果 2, 启动动画 3,因为布局容器中添加android:animateLayoutCha...

  • iOS获取启动图

    获取App启动图的方法 为启动图添加一个动画效果 NSString转NSData NSData转NSString

  • iOS启动页动画效果

    最近项目中要在启动页增加版本号,因为版本号是不断的改变,所以要动态实现把它加到启动页上;在XCode上面配置的La...

  • PPT制作汉字模拟书写动画

    不废话,先来看模拟书写动画的效果。 Flash等动画软件这类效果很好实现,PPT中呢,其实也可以,原理也基本类似。...

  • iOS代码添加视图约束

    项目要做这样一个效果的启动页。 考虑到版本号是会不断变更的,因此采用动画效果启动页,让版本号动态加载iOS启动页动...

网友评论

本文标题:软件的启动动画效果

本文链接:https://www.haomeiwen.com/subject/iwbzjttx.html