我需要向 UINavigationItem 添加一个按钮titleView
(实际上是导航栏的中心。
我使用以下代码来完成此任务:
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(0, 0, 70, 30);
[btn setSelected:YES];
[btn setTitle:@"list" forState:UIControlStateNormal];
我已经进行了以下操作:
我需要提供相同样式的“完成”按钮(即UIBarButtonItem
)到“列表”按钮?
您可以使用 UISegmentedControl:
UISegmentedControl *mySegmentedControl = [[UISegmentedControl alloc]
initWithItems:@"Example"]];
mySegmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
[mySegmentedControl addTarget:self action:@selector(myMethod)
forControlEvents:UIControlEventValueChanged];
self.navigationItem.titleView = mySegmentedControl;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)