How can I make the buttons in an application draggable and droppable just like in OS' home screen?
So far I see two ways to animate stuff –
UIView
methods which provide animation for frame
, bounds
, centre
, transform
and alpha
Core Animation
, which I'm not familiar with.I was able to move a UIImageView
object. Will the same apply for moving a UIButton
object?
My code for moving a UIImageView
object is:
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
imageView.center = location;
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesBegan:touches withEvent:event];
}
Can I use this same code for moving the button?
If you mean something similar to the facebook launcher screen, which has arrangeable icons, i recommending taking a look on the three20 framework (which powers the facebook iphone app): http://three20.info
The TTLauncherView (http://three20.info/showcase/launcher) supports reordering and deletion of items, custom column and row counts, and multiple pages of content. It also works on the iPad.
It's amazing how much time it can save you. It's mostly bug-free and ready to use.