【发布时间】:2013-04-28 05:37:21
【问题描述】:
我在我的应用程序中使用 UINavigationController 及其栏。 现在我想改变 leftBarButtonItem 和 rightBarButtonItem 的位置。 我希望它们位于具有自定义宽度和高度的不同 x 和 y 位置。
但问题是,改变框架并不会改变 barButtonItem 的任何内容。我现在不知道为什么,但框架总是被重置为其原始坐标。
这是我在 viewWillAppear 中调用的代码:
UINavigationItem *navItem = [[self.navigationBar items] lastObject];
UIView *rightview = [[UIView alloc] initWithFrame:CGRectMake(0,0,66,30)];
rightview.backgroundColor = [UIColor blueColor];
//add custom view
UIBarButtonItem *search = [[UIBarButtonItem alloc] initWithCustomView:rightview];
navItem.leftBarButtonItem = search;
视图不是从 0/0 开始,例如 x 位置在 0 的内插 5px 处。
关于如何解决这个问题的任何建议?
【问题讨论】:
标签: objective-c ios uitoolbaritem