【发布时间】:2011-05-08 08:41:01
【问题描述】:
是否可以移动 UIToolBar?以下代码不起作用
CGRect toolbarFrame = self.tryToolbar.frame;
toolbarFrame.origin.y = 10;
self.tryToolbar.frame = toolbarFrame;
但是我已经阅读了涉及工具栏的动画示例,所以我想它会起作用。谢谢
【问题讨论】:
标签: iphone cocoa-touch uitoolbar
是否可以移动 UIToolBar?以下代码不起作用
CGRect toolbarFrame = self.tryToolbar.frame;
toolbarFrame.origin.y = 10;
self.tryToolbar.frame = toolbarFrame;
但是我已经阅读了涉及工具栏的动画示例,所以我想它会起作用。谢谢
【问题讨论】:
标签: iphone cocoa-touch uitoolbar
移动对象的更好方法是使用 CGRectMake。这是一个移动工具栏的示例,它也会为其运动设置动画。
[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];
有了这个,你可以改变它向左/向右移动的量(通过添加或减去 x)或向上/向下移动(添加/减去到 y)
【讨论】: