我试图通过将右侧栏按钮项更改为经典信息灯来自定义导航栏。由于我不想使用导航控制器,因此在链接的问题中提出的代码无法正常工作。
iPhone:在代码的导航栏中将“信息”按钮添加为右键栏按钮项
有谁知道如何在不实现导航控制器的情况下更改barButtonItem的外观?
试试这个。
UIButton *btn = [UIButton buttonWithType:UIButtonTypeInfoDark];
UIBarButtonItem *barButton= [[UIBarButtonItem alloc] initWithCustomView:btn];
UIView *barButtonView = [barButton valueForKey:@"view"];
barButtonView.frame = CGRectMake(self.view.frame.size.width-barButtonView.frame.size.width,
0,
barButtonView.frame.size.width,
barButtonView.frame.size.height);
[self.view addSubview:barButtonView];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句