动画

mark:
iOS那些简单的动画(不定期更新)

iOS动画详解(学习动画看这一篇就够了)

ios�平移与抖动动画的简单实现

热门动画的集合demo

    [UIView animateWithDuration:.5 delay:0 usingSpringWithDamping:0.6 initialSpringVelocity:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        self.settingAdreView.frame =CGRectMake(5,(ScreenHeight-64-49)/2-350/2, settingAdreViewW, settingAdreViewH);
    } completion:^(BOOL finished) {
        
    }];
- (void)createGoodsDetailViewWithShoppingType:(XYShoppingType)shoppingType{
    
    XYGoodsDetailView *xycv = [XYGoodsDetailView createXYGoodsDetailViewWithDelegate:self xYGoodsInfo:_xYGoodsInfo allOtherList:_allOtherList shoppingType:shoppingType bannerList:_bannerList xlOrderForm:(XlOrderForm *)_xlOrderForm];
    
    UIWindow *keywindow = [UIApplication sharedApplication].delegate.window;
    //    UIWindow *keywindow = [[UIApplication sharedApplication] keyWindow];
    xycv.frame = [UIScreen mainScreen].bounds;
        [keywindow  addSubview:xycv];
    xycv.blackBackground.alpha=0.0;
    xycv.frame = CGRectMake(0, ScreenHeight, ScreenWidth, ScreenHeight);
    [UIView animateWithDuration:0.3 animations:^(void) {
        xycv.blackBackground.alpha=0.5;
        xycv.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
        //此处可做UIView渐变效果以及飞出效果
    } completion:^(BOOL finished) {
    }];
//    [self addDetailViewWithAnimationWithHolderView:xycv];
}

- (void)childViewRemoveFromSuperview{
    
    self.blackBackground.alpha=0.0;
    [UIView animateWithDuration:0.3 animations:^(void) {
        
        self.frame = CGRectMake(0, ScreenHeight, ScreenWidth, ScreenHeight);
        //此处可做UIView渐变效果以及飞出效果
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];

上面这种动画的好处在于动画过程可控,而且还可以用于removeFromSuperview这种特殊的情况。但是麻烦,像这种动画弹出收起的效果要通过set Frame来实现。

//动画
- (void)addAnimationWithCurrentAnimationView:(UIView *)CurrentAnimationView{
    CATransition *animation = [CATransition animation];
    animation.type = @"push";
    animation.subtype = kCATransitionFromTop;
    animation.duration = 0.2;
    [CurrentAnimationView.layer addAnimation:animation forKey:nil];
}

第二种方法的优点在于效果可选的多,方便使用,缺点是动画不可控。另外要特别注意的是动画view,本身的layer层加动画。比如说我要在keyWindow上add一个subView,那么就是subView的layer加动画而不是keyWindow

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容