app启动图的渐变

2016-04-14  本文已影响195人  7dfa9c18c1d1
主要是写登录图
原理
- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIViewController *viewController = [[UIStoryboard storyboardWithName:@"LaunchScreen" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"LaunchScreen"];
    UIView *launchView = viewController.view;
    UIImageView  * Imageview= [[UIImageView  alloc]initWithFrame:[UIScreen mainScreen].bounds];
    Imageview.image = [UIImage imageNamed:@"baidu2"];
    [launchView addSubview:Imageview];
    [self.view addSubview:launchView];
    
    
    [UIView animateWithDuration:6.0f delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState animations:^{
//        launchView.layer.transform = CATransform3DRotate(CATransform3DIdentity, M_PI_4, 1.5f, 1.5f, 1.5f);
        launchView.transform = CGAffineTransformMakeTranslation(0.0f, 0.1f);
    } completion:^(BOOL finished) {
        
        UIImageView *imgViewAd = [[UIImageView alloc] init];
        imgViewAd.frame = [UIScreen mainScreen].bounds;
        imgViewAd.image = [UIImage imageNamed:@"me"];
        [[UIApplication sharedApplication].keyWindow addSubview:imgViewAd];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [UIView animateWithDuration:.25
                             animations:^{
                                 imgViewAd.alpha = 0.0f;
                             }
                             completion:^(BOOL finished) {
                                 [imgViewAd removeFromSuperview];
                             }];
        });
        [launchView removeFromSuperview];
    }];
    
}


补充

最后那个动画方法,好像里面不设置下launchView的形变,就直接不显示launchView上后添加的图片(其实是时间太快,我们没有来得及看到),所以我想了这个笨方法,设置下LaunchView的形变,不明显的形变

上一篇 下一篇

猜你喜欢

热点阅读