美文网首页
iOS弹窗动画

iOS弹窗动画

作者: 今年27 | 来源:发表于2020-09-27 10:26 被阅读0次
- (void)showInView:(UIView*)view{
    [view addSubview:self];
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(view);
    }];
    
    CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    animation.duration      = 0.15;
    animation.repeatCount   = 1;
    animation.fromValue     = @0.0;
    animation.toValue       = @1.0;
    [self.innerView.layer addAnimation:animation forKey:@"scale-show-layer"];

}

关于这个RemovedOnCompletion和kCAFillModeForwards设置
如果设置了这两个属性,就不会在动画结束后恢复原样,而是保持弹窗动画后的样子

 CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    animation.duration      = 0.15;
    animation.repeatCount   = 1;
    animation.fromValue     = @1.0;
    animation.toValue       = @0.0;
    
    //设置结束状态
    [animation setRemovedOnCompletion:NO];
    animation.fillMode = kCAFillModeForwards;
    [self.innerView.layer addAnimation:animation forKey:@"scale-show-layer"];

相关文章

网友评论

      本文标题:iOS弹窗动画

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