繁体   English   中英

在导航栏的右侧看不到自定义uibarbuttonitem

[英]Can't See Custom uibarbuttonitem at Right side of navigation bar

我正在尝试在导航栏的右侧添加自定义导航栏按钮。

这是我的代码。

UIButton *customPrintButton = [UIButton buttonWithType:UIButtonTypeCustom];
[customPrintButton setFrame:CGRectMake(0, 0, 100, 30)];
[customPrintButton.titleLabel setTextColor:[appDelegate getAppPinkColor]];
[customPrintButton setTitle:@"Print" forState:UIControlStateNormal];
[customPrintButton setBackgroundColor:[UIColor clearColor]];
[customPrintButton setExclusiveTouch:YES];
[customPrintButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
[customPrintButton.titleLabel setFont:[UIFont systemFontOfSize:20]];
[customPrintButton addTarget:self action:@selector(printOutButton_Clicked) forControlEvents:UIControlEventTouchUpInside];

printOutBtn = [[UIBarButtonItem alloc]initWithCustomView:customPrintButton];
self.navigationItem.rightBarButtonItem = printOutBtn;

但我仍然看不到页面上的按钮。

我忘了加标题颜色了。

这就是为什么默认将白色作为文本颜色的原因

谢谢您的回复。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM