【发布时间】:2011-04-11 01:08:17
【问题描述】:
我想问一下UIButton位置可以翻译吗?
怎么样?有人吗?
【问题讨论】:
标签: iphone objective-c ios4
我想问一下UIButton位置可以翻译吗?
怎么样?有人吗?
【问题讨论】:
标签: iphone objective-c ios4
您可以使用“frame”属性获取按钮的框架。这将返回一个 CGRect 对象,它基本上具有您的按钮 x 坐标、y 坐标、宽度和高度。
根据您要翻译按钮的位置,计算新的 x 坐标和 y 坐标。 然后执行以下操作:
btnMyButton.frame = CGRectMake(oldx,oldy,width,height);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:btnMyButton];
[UIView setAnimationDuration:0.3];
btnMyButton.frame = CGRectMake(newx, newy, width, height);
[UIView commitAnimations];
【讨论】: