UIBarButtonItem在navbar的中间? [英] UIBarButtonItem in middle of navbar?

查看:103
本文介绍了UIBarButtonItem在navbar的中间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程式中建立了一个弹性导览列,会在左侧,右侧和中间显示自订按钮。到目前为止我已经工作了:

I have created a flexible navigation bar in my app that will show custom buttons on the left, right, and in the middle. So far I have got working:


  • 右/左/中 - 自定义图片和/或文字

  • 右/左 - 自定义图片的正常查看按钮

  • 右/左 - 自定义文本的正常查看按钮

通过'正常查看'我的意思是默认的UIBarButtonItemStyle-只是一个很好的闪亮按钮。

By 'normal looking' I mean the default UIBarButtonItemStyle- just a nice shiny button.

我的问题是,在导航栏的中间相同的外观吗?我可以通过创建自定义UIButton做自定义/文本图像,在右/左我从它创建一个UIBarButtonItem,但在中间,我只是添加UIButton视图作为导航栏的子视图。

My question is, how can I achieve the same look in the MIDDLE of the nav bar? I can do custom/text images by just creating a custom UIButton, and on the right / left I create a UIBarButtonItem from it, but in the middle I just add the UIButton view as a subview of the navbar.

我无法将UIBarButtonItem添加到navbar作为子视图,我创建的任何UIButton看起来不像UIBarButtonItem。

I can't add a UIBarButtonItem to the navbar as a subview, and any UIButton I create doesn't look like a UIBarButtonItem.

我可以想到的唯一解决方法是使用一个可伸缩的自定义图像,我从一个截图窃取。我宁愿避免这样做。我错过了什么?

The only workaround I can think of is to use a stretchable custom image that I steal from a screenshot. I'd rather avoid doing it this way. Am I missing something?

*********** UPDATE **************
开源库Three20将允许您创建看起来像UIBarButtonItems的UIButtons。

*********** UPDATE ************** The open source library Three20 will allow you to create UIButtons that look like UIBarButtonItems. Then you can add them to the bar view either by placing manually as a subview or by setting the title view.

推荐答案

我从来没有理解为什么他们没有使UIBarButtonItems从UIViews派生(或更好,UIButtons),所以他们可以在其他地方使用。

I never understood why they didn't make UIBarButtonItems derive from UIViews (or even better, UIButtons) so they could be used elsewhere.

听起来像你在正确的轨道,但需要更好的图片:-)您可以在Photoshop的.PSD文件中获得大量的iPhone UI组件从这里。它们具有预呈现的条形按钮,您可以将其用作标准UIButton图像的基础。如果你有Photoshop(或一个体面的绘图程序),你可以从中间拉伸按钮,以适应你的大小,而不会使角落扭曲。只需添加标签,您应该就可以了。

Sounds like you're on the right track, but need better artwork :-) You can get a large number of iPhone UI components in a Photoshop .PSD file from here. They have pre-rendered bar buttons which you can use as a base for a standard UIButton image. If you have Photoshop (or a decent drawing program) you can stretch the buttons from the middle to fit your size without getting the corners distorted. Just add the label and you should be good to go.

这篇关于UIBarButtonItem在navbar的中间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆