关于进入App前几秒引导动画效果

      前几天见到一个比较有意思的一个东西。虽然没有什么技术难点,但感觉还是挺有意思的。就是在用户初次启动App时,会有一个引导页面。当用户第二次运行的时候就不会有了。

     先说一下我个人的见解吧。这个其实是在用户运行App时,将是否运行过这个App的信息存储在userdefault中。当用户在运行一次后,userdefault中的key对应有值,走的if另个分支。下边看代码:

      在AppDelegate中:

    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];

    NSString *isFirst = [user objectForKey:@"first"];//任意定义一个key,使得App第一次运行时没有值,走if中的else语句

    

if(isFirst){//不是第一次,只有一张图片引导

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

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

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

        [self.window addSubview:imageView];


    }else{//第一次,设置一个动画效果来引导用户

        FirstRunViewController *first = [[FirstRunViewController alloc] init];

        [user setObject:@"first" forKey:@"first"];

        [user synchronize];

        self.window.rootViewController = first;

    }


FirstRunViewController中的viewDidLoad:
  

    NSArray *pictures = @[@"intro1",@"intro2",@"intro3",@"intro4",@"intro5"];//这是几张引导图片

    UIScrollView *_scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];

    for(NSInteger i=0;i<pictures.count;i++)

    {

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

        iamgeView.image = [UIImage imageNamed:pictures[i]];

        [_scrollView addSubview:iamgeView];

        

        if(i==4){//最后一张添加点击手势

            iamgeView.userInteractionEnabled = YES;

            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap)];

            [iamgeView addGestureRecognizer:tap];

        }

    }

    _scrollView.pagingEnabled = YES;

    _scrollView.contentSize = CGSizeMake(320*pictures.count, 480);

    [self.view addSubview:_scrollView];



//点击手势对应的方法,跳转到应用中

- (void)onTap

{

    RootViewController *root = [[RootViewController alloc] init];

    [self presentViewController:root animated:YES completion:^{

        

    }];

}



当然以上是个人愚见,个人感觉比较好理解一些。欢迎指错,谢谢

    

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值