Moving UIToolBar

我是研究僧i 提交于 2019-12-08 04:18:12

问题


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


回答1:


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)



来源:https://stackoverflow.com/questions/5926446/moving-uitoolbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!