您好,欢迎来到化拓教育网。
搜索
您的当前位置:首页视图模糊到清晰的动画效果

视图模糊到清晰的动画效果

来源:化拓教育网

实现原理:1、使用UIVisualEffectView构建模糊视图 ;2、使用UIViewPropertyAnimator来实现动画效果。(ios10以后才出现的这个类)

直接看代码:

    //毛玻璃效果
    UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
     effectView.frame = CGRectMake(0,0,100,100);
    [cricleView addSubview:effectView];
//设置动画时长,动画效果(用法和 [UIView animateWithDuration:<#(NSTimeInterval)#> animations:<#^(void)animations#>]差不多,但多了很多动画的控制操作,开始,暂停,动画完成百分比等)
    self.animator = [[UIViewPropertyAnimator alloc] initWithDuration:5 curve:UIViewAnimationCurveLinear animations:^{
        effectView.effect = nil;
    }];
  //开始
    [self.animator startAnimation];

兼容ios10之前则用常规的写法:(替代UIViewPropertyAnimator的使用)

    [UIView animateWithDuration:5 animations:^{
         effectView.effect = nil;
    }];

Copyright © 2019- huatuo9.cn 版权所有 赣ICP备2023008801号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务