bar按钮坚持y原点为0到导航栏,x为0.但是我想在barbutton项目中添加一些y位置。
UIBarButtonItem *barbutton;
barbutton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(onbackbtnpressed:)];
[barbutton setWidth:30];
[barbutton setTintColor:KANEKA_BLUE_COLOR];
[barbutton setAccessibilityFrame:CGRectMake(10, 10, 30, 20)];
self.navigationItem.leftBarButtonItem = barbutton;
请告诉我如何设置条形按钮框架或如何设置条形按钮y位置。
答案 0 :(得分:1)
实际上我已经设法以稍微不同的方式设置y原点可能是大程序但是它非常好。
我为viewcontroller添加了一个工具栏并设置了bar按钮项并隐藏了导航栏。它适用于所有popover控制器。
self.toolbar.hidden = NO;
self.contentSizeForViewInPopover = CGSizeMake(self.view.frame.size.width-100,self.view.frame.size.height-100);
self.navigationController.navigationBarHidden = YES;
[self.toolbar setTintColor:KANEKA_BLUE_COLOR];
[self.backbutton setTintColor:KANEKA_BLUE_COLOR];
答案 1 :(得分:0)
我对此问题的看法 - 根据iOS人机界面指南,建议不要在导航栏上为条形按钮项添加y间距。
我们可以通过设置导航项的按钮数组来更新x定位,如下所示:
UIBarButtonItem *fixedSpaceBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
[fixedSpaceBarButton setWidth:10];
UIBarButtonItem *barbutton;
barbutton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(onbackbtnpressed:)];
[barbutton setWidth:30];
[barbutton setTintColor:[UIColor redColor]];
[barbutton setAccessibilityFrame:CGRectMake(10, 10, 30, 20)];
self.navigationItem.leftBarButtonItems = [NSArray
arrayWithObjects:fixedSpaceBarButton, barbutton, nil];