如何创建 UIView 波纹圆圈动画?
How to create UIView ripple circle animation?
我想创建这样的 UIView 动画link
我已经在 ViewDidLoad() 中尝试了所有这些代码,但没有用
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];
[view.layer addAnimation:animation forKey:nil];
[self.view addSubview:view];
我想在 iOS 中创建相同的东西。请帮助我
希望对您有所帮助Sample class
UIView+Glow 是 UIView 上的一个类别,它增加了对使视图发光的支持(有助于突出显示屏幕的一部分以鼓励用户与之交互)。
要了解它的用途和使用方法,请查看 blog post
您的以下几行代码看起来不错:
CATransition *animation=[CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.75];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
[animation setType:@"rippleEffect"];
[view.layer addAnimation:animation forKey:nil];
但是,问题在于您在将视图添加到其父视图之前应用了动画。这显然行不通!
尝试添加子视图然后应用动画。我也希望这不会起作用。
如果您在 viewDidLoad
方法中将此视图添加到其父视图。在 ViewDidAppear 或 ViewWillAppear 方法中应用动画。
否则,创建一个应用动画的单独方法。并在通过调用 performSelector:withObject:afterDelay
方法添加子视图后调用它。
我想创建这样的 UIView 动画link
我已经在 ViewDidLoad() 中尝试了所有这些代码,但没有用
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];
[view.layer addAnimation:animation forKey:nil];
[self.view addSubview:view];
我想在 iOS 中创建相同的东西。请帮助我
希望对您有所帮助Sample class
UIView+Glow 是 UIView 上的一个类别,它增加了对使视图发光的支持(有助于突出显示屏幕的一部分以鼓励用户与之交互)。
要了解它的用途和使用方法,请查看 blog post
您的以下几行代码看起来不错:
CATransition *animation=[CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.75];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
[animation setType:@"rippleEffect"];
[view.layer addAnimation:animation forKey:nil];
但是,问题在于您在将视图添加到其父视图之前应用了动画。这显然行不通!
尝试添加子视图然后应用动画。我也希望这不会起作用。
如果您在 viewDidLoad
方法中将此视图添加到其父视图。在 ViewDidAppear 或 ViewWillAppear 方法中应用动画。
否则,创建一个应用动画的单独方法。并在通过调用 performSelector:withObject:afterDelay
方法添加子视图后调用它。