1

我正在尝试将仪表板应用程序中看到的涟漪效应带到 iphone。我的想法是每当我在布局视图中放置一个按钮时,按钮周围都应该有涟漪效应。但是,我能够为整个视图带来涟漪效果,但我只需要按钮周围的效果。我不知道我哪里出错了。我尝试了以下代码。

LayoutButton *tempLayoutButton=[[LayoutButton alloc] initWithObject:object];
tempLayoutButton.center=copyImage.center;
[layoutView addSubview:tempLayoutButton];  
CALayer *templayer=[CALayer layer];
tempLayoutButton.layer.masksToBounds=NO;
templayer.frame=CGRectMake(0,0,50,50);
[tempLayoutButton.layer addSublayer:templayer];

CATransition *animation = [CATransition animation];
animation.delegate = self;
animation.duration = 1.0f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.type = @"rippleEffect";
[templayer  addAnimation:animation forKey:@"animation"];
[tempLayoutButton release];
[tempLayoutButton.layer addSublayer:templayer];

如果我用 LayoutView 层替换 templayer,我可以从整个视图中看到涟漪效应。谁能告诉我解决方案

提前致谢

4

1 回答 1

1

我在其中一个苹果邮件列表中找到了答案。动画是苹果自己的动画,没有人可以使用。并且不能保证动画在屏幕上正确显示。如果我们需要相同类型的动画,我们需要操作图层并获取动画

于 2010-11-08T03:38:30.710 回答