2011-04-10 67 views

回答

1

您可以使用「frame」屬性獲取按鈕的框架。這將返回一個CGRect對象,它基本上包含您的按鈕x-coord,y-coord,width和height。

根據您想要翻譯按鈕的位置,計算新的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];