UIView surface custom transformation/animation (like 'a water drop effect')

后端 未结 2 1169
余生分开走
余生分开走 2021-02-09 16:21

What is the way to implement custom transformation (+ animation) on a view surface (similar to the images attached) (not

2条回答
  •  南笙
    南笙 (楼主)
    2021-02-09 17:00

    You can use this:

    - (void)drawWaterRippleAnimation {
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(200, 200, 100, 100)];
        view.backgroundColor = [UIColor blueColor];
    
        CATransition *animation=[CATransition animation];
        [animation setDelegate:self];
        [animation setDuration:1.75];
        [animation setTimingFunction:UIViewAnimationCurveEaseInOut];
        [animation setType:@"rippleEffect"];
    
        [animation setFillMode:kCAFillModeRemoved];
        animation.endProgress=1;
        [animation setRemovedOnCompletion:NO];
        [self.view.layer addAnimation:animation forKey:nil];
    }
    

    Credits goes to here.

提交回复
热议问题