2010-08-30 89 views
1

我正试图将在仪表板应用程序中看到的涟漪效应带给iphone。我的想法是每当我在布局视图中放置一个按钮时,都应该在按钮周围产生波纹效果。 但是,我能够为整个视图带来涟漪效果,但我只需要在按钮周围获得效果。我不知道我出错的地方。我试了下面的代码。动画UIButton图层?

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我可以看到从整个视图中riple效果。谁能告诉我该解决方案提前

回答

1

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