0

I would like to ask is it possible to translate the UIButton position?

How? Anyone?

1 Answer 1

1

You can get the frame of the button using "frame" property. This returns a CGRect object which basically has your buttons x-coord, y-coord, width and height.

Based on where you want to translate your button, calculate the new x-coord and y-coord. Then do the following:

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];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.