【问题标题】:UIBarButtonItem does not appear to respond to "style" propertyUIBarButtonItem 似乎没有响应“样式”属性
【发布时间】:2010-06-03 04:03:29
【问题描述】:

情况:我正在将一个系统“项目操作”按钮的实例放入右侧导航按钮槽中......那里没有问题。但是,我希望该按钮仅显示为没有边框的图标(即:“普通”样式)。阅读文档,听起来这应该很简单,只需将 UIBarButtonItem 的“样式”属性设置为 UIBarButtonItemStylePlain,如下所示:

UIBarButtonItem *shareButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(didPressShare)];    
    shareButton.style = UIBarButtonItemStylePlain;
    self.navigationItem.rightBarButtonItem = shareButton;
    [shareButton release];

但是,当我实现上面的代码时,按钮出现在导航栏中,周围有一个边框......显然系统没有观察我的 UIBarButtonItemStylePlain 设置。关于为什么的任何想法?是否有任何其他解决方案可以使按钮仅显示图标而周围没有边框?

提前致谢!

【问题讨论】:

    标签: iphone objective-c


    【解决方案1】:

    很抱歉告诉你,但据我所知你不能在 UINavigationBar 中使用普通样式。 如果可能,请改用 UIToolbar。

    【讨论】:

    • 啊……这很有道理。我什至从未想过他们可能会完全阻止特定的按钮样式,但现在你提到它——这听起来非常像 Apple 和他们的 UI 一致性策略在起作用。感谢您的回复!
    • 随意将其标记为正确答案(检查左侧的视线)。或者使用“这个答案很有用”。我看到你从来没有在你的 prev 中使用过这些按钮。问题。
    • 啊,感谢有关堆栈溢出使用的提示...是的,我是刚接触系统的新手。在我获得 15 级之前仍然无法投票!
    • 你需要创建自己的 UIBbutton,看到这个答案:stackoverflow.com/questions/2348440/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-22
    • 2021-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-27
    相关资源
    最近更新 更多