pistacchio
pistacchio

Reputation: 58953

Moving UIToolBar

Is it possible to move a UIToolBar? The following code doesn't work

CGRect toolbarFrame = self.tryToolbar.frame;
toolbarFrame.origin.y = 10;
self.tryToolbar.frame = toolbarFrame;

but I've read examples of animations involving toolbars, so I guess it would work. Thanks

Upvotes: 1

Views: 1493

Answers (1)

shabbirv
shabbirv

Reputation: 9098

A better way of moving objects is using CGRectMake. Here is an example of moving a toolbar, it will also animate its motion.

[UIView beginAnimations: @"moveField"context: nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration: 0.5];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
self.tryToolbar.frame = CGRectMake(self.tryToolbar.frame.origin.x,
                             self.tryToolbar.frame.origin.y + 10,
                             self.tryToolbar.frame.size.width,
                             self.tryToolbar.frame.size.height);
[UIView commitAnimations];

With this you can change how much it moves left/right (by adding or subtracting to x) or up/down by (adding/subtracting to y)

Upvotes: 3

Related Questions