首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使UIBarButtonSystemItems显示在圆形矩形按钮中,而不仅仅是它们自己

使UIBarButtonSystemItems显示在圆形矩形按钮中,而不仅仅是它们自己
EN

Stack Overflow用户
提问于 2012-08-16 10:57:59
回答 1查看 605关注 0票数 0

我用以下代码以编程方式在工具栏上包含了一个操作按钮和一个合成按钮:

代码语言:javascript
运行
复制
UIBarButtonItem *compose = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:7 target:self action:@selector(userWritesHaiku)];

compose.style=UIBarButtonItemStyleBordered;

UIBarButtonItem *action = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:9 target:self action:@selector(userWritesHaiku)];

action.style=UIBarButtonItemStyleBordered;

(然后将它们放入一个数组中,并将它们分配给工具栏。)

但这给了我以下输出:

我想要的是以下内容,我可以使用Interface Builder创建它,但我没有使用Interface Builder。

如何以编程方式获取后一幅图像?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-16 11:01:22

该项的style属性的默认值为UIBarButtonItemStylePlain。您需要将其设置为UIBarButtonItemStyleBordered

我在iOS 5.0模拟器中尝试了以下代码:

代码语言:javascript
运行
复制
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(self)];
//item.style = UIBarButtonItemStyleBordered;
self.toolbar.items = [self.toolbar.items arrayByAddingObject:item];

我得到的结果是:

然后,我将其更改为以下代码:

代码语言:javascript
运行
复制
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(self)];
item.style = UIBarButtonItemStyleBordered;
self.toolbar.items = [self.toolbar.items arrayByAddingObject:item];

我得到了这样的结果:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11980130

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档