我创建了一个自定义视图leftBarButtonItem,但它没有左对齐,我还在调试器上找到了一个UInavigationBarBackIndicatorView,但看不见,我想左对齐UInavigationBarBackIndicatorView。
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 30)];
view.backgroundColor = [UIColor redColor];
UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:view];
self.navigationItem.leftBarButtonItem = leftItem;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close"
style:UIBarButtonItemStylePlain
target:self
action:@selector(cancel)];Debuger View:
I wish
发布于 2016-04-19 13:52:56
我希望这能帮助你实现你正在寻找的东西。
UIButton *aBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 50, 30)];
aBtn.backgroundColor = [UIColor redColor];
UIBarButtonItem *spacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
spacer.width = -13.0;
self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:spacer, aBtn, nil];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close"
style:UIBarButtonItemStylePlain
target:self
action:@selector(cancel)];别忘了给按钮添加一个动作。
https://stackoverflow.com/questions/36708222
复制相似问题