移动UIToolBar [英] Moving UIToolBar

查看:119
本文介绍了移动UIToolBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以移动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

推荐答案

移动对象的更好方法是使用CGRectMake。

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

使用这个选项,您可以改变左/右移动量上/下(加/减y)

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)

这篇关于移动UIToolBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆