【问题标题】:Animating the UIButton Layer?动画 UIButton 层?
【发布时间】:2010-08-30 11:13:09
【问题描述】:

我正在尝试将仪表板应用程序中看到的涟漪效应带到 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,我可以从整个视图中看到涟漪效应。谁能告诉我解决办法

提前致谢

【问题讨论】:

    标签: objective-c animation button layer


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-09
      • 2013-01-06
      相关资源
      最近更新 更多