【问题标题】:UIView beginAnimations is too fast on custom propertyUIView beginAnimations 在自定义属性上太快了
【发布时间】:2012-06-06 18:17:50
【问题描述】:

我将 UIButton 子类化以创建自己的 UIRoundButton。我正在尝试为一个名为 radius 的自定义属性设置动画。它确实发生了变化,但它立即发生了变化。我尝试将动画持续时间增加到 5000,但动画仍在毫秒内发生。

代码如下:

UIRoundButton *tempItem = [self.buttons objectAtIndex:currentElement];
[tempItem setInnerColor:UIColorFromRGB(0xcdcdcd)];

currentElement = currentElement + 1;
UIRoundButton *tempItem2 = [self.buttons objectAtIndex:currentElement];
[tempItem2 setInnerColor:UIColorFromRGB(0xff0000)];

[UIView beginAnimations:@"ToggleViews" context:nil];
[UIView setAnimationDuration:5000];
tempItem.radius = 20;
tempItem2.radius = 40;
[UIView commitAnimations];

有什么想法吗?

【问题讨论】:

    标签: ios uiview core-animation


    【解决方案1】:

    隐式视图动画不适用于自定义属性。如果您想要这种行为,则必须在 CALayer 级别执行此操作。

    【讨论】:

    • 哎哟 :) 好的,我会试着告诉你一些事情。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-30
    • 2011-01-14
    • 1970-01-01
    相关资源
    最近更新 更多