【发布时间】:2014-04-02 16:07:17
【问题描述】:
我在将 UIButton 设置为新位置时遇到问题。
我使用的代码如下:
[UIView animateWithDuration:kFadeAnimationInterval
animations:^{
button.frame = newFrame;
}];
执行代码对按钮的位置没有任何影响。 不确定它是否相关,但接口是在一个 NIB 文件中布局的。
有什么建议吗?
【问题讨论】:
-
你用什么方法调用这段代码?你检查那个按钮不是 nil 吗?
-
@suprandr 在插入一些子视图后,我在视图控制器中的自定义方法中调用它。
-
按钮是否通过插座连接(如果它驻留在 xib 中)?
-
确保你在主线程中进行操作
-
@Andrea 是的,我有一个引用按钮的 IBOutlet。
标签: ios objective-c uiview uibutton uiviewanimation