Objective C:工具栏中 UIBarButton 缺少边框
我试图创建一个 UIBarButton 并使用代码将其添加到工具栏。运行应用程序后,我发现按钮的边框丢失了。我的代码如下所示。
//Add toolbar to the UITable View
toolbar = [[UIToolbar alloc] init];
toolbar.barStyle = UIBarStyleDefault;
toolbar.frame = CGRectMake(0, 436, 320, 50);
//Set the toolbar to fit the width of the app.
[toolbar sizeToFit];
UIBarButtonItem *flexButton =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
UIBarButtonItem *nextButton = [[UIBarButtonItem alloc]initWithTitle:@"Who Paid?"
style:UIBarButtonItemStylePlain
target:self
action:nil];
NSArray *buttonItems = [[NSArray alloc]initWithObjects:flexButton, nextButton, nil];
[self.toolbar setItems:buttonItems];
[self.navigationController.view addSubview:toolbar];
[buttonItems release];
[flexButton release];
[nextButton release];
[toolbar release];
我是否错过了任何步骤或者是否犯了错误?非常感谢对此的任何帮助。
谢谢!
珍
I was trying to create a UIBarButton and add it to a tool bar using code. I fount the border of my button missing after running the app. My code as shown below.
//Add toolbar to the UITable View
toolbar = [[UIToolbar alloc] init];
toolbar.barStyle = UIBarStyleDefault;
toolbar.frame = CGRectMake(0, 436, 320, 50);
//Set the toolbar to fit the width of the app.
[toolbar sizeToFit];
UIBarButtonItem *flexButton =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
UIBarButtonItem *nextButton = [[UIBarButtonItem alloc]initWithTitle:@"Who Paid?"
style:UIBarButtonItemStylePlain
target:self
action:nil];
NSArray *buttonItems = [[NSArray alloc]initWithObjects:flexButton, nextButton, nil];
[self.toolbar setItems:buttonItems];
[self.navigationController.view addSubview:toolbar];
[buttonItems release];
[flexButton release];
[nextButton release];
[toolbar release];
Am I missing out on any step or is there a mistake that was made? Any help on this is greatly appreciated.
Thanks!
Zhen
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UIBarButtonItemStylePlain
是罪魁祸首。根据 Apple 文档,< strong>
UIBarButtonItemStyleBordered
是您所需要的:UIBarButtonItemStylePlain
is the culprit.According to Apple documentation,
UIBarButtonItemStyleBordered
is what you need :