iOS5工具栏背景图片 [英] iOS5 Toolbar background image
本文介绍了iOS5工具栏背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是iOS编程的新手。
我正在尝试将工具栏背景设置为自定义图像。
我也在使用故事板。
我该怎么做?
我是否在UI Kit框架中编辑UIToolbar?我是否需要在故事板中更改内容?
I'm very new to iOS programming. I'm trying to set the toolbar background to a custom image. I'm also using storyboards. How do I go about that? Do I edit UIToolbar in the UI Kit framework? Do I need to change something in Storyboard?
谢谢,
推荐答案
您可以使用 UIToolbar
的内置 -setBackgroundImage:forToolbarPosition:barMetrics:
方法:
You can use UIToolbar
's built-in -setBackgroundImage:forToolbarPosition:barMetrics:
method:
// portrait
[yourToolbar setBackgroundImage:[UIImage imageNamed:@"YourToolbarBkg-Portrait.png"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
// landscape
[yourToolbar setBackgroundImage:[UIImage imageNamed:@"YourToolbarBkg-Landscape.png"] forToolbarPosition:UIToolbarPositionAny barMetrics: UIBarMetricsLandscapePhone];
-
YourToolbarBkg-Portrait.png $对于横向模式,c $ c>将为320x44 bkg图像用于纵向模式
-
YourToolbarBkg-Landscape.png
将为横向模式的480x32 bkg图像。 YourToolbarBkg-Portrait.png
will be 320x44 bkg image for portrait modeYourToolbarBkg-Landscape.png
will be 480x32 bkg image for landscape mode.
这篇关于iOS5工具栏背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文