我正在试图弄清楚如何制作使用系统图标或图像图标的自定义导航栏按钮.我按照下面的教程如何设置自定义导航栏背景,并创建自定义文本按钮,现在我想创建像教程中的按钮,但w /图标而不是文本.
http://idevrecipes.com/2010/12/13/wooduinavigation/
有谁知道如何创建带图标的自定义导航栏按钮?
谢谢!
本教程使用initWithCustomView创建一个UIBarButtonItem对象:基本上你可以使用它来制作一个带有自定义图像的按钮.您所要做的就是使用自定义视图创建一个视图,并将其作为initWithCustomView:的参数传递.
或者,更容易创建一个包含自定义图像的UIImage对象,并使用initWithImage:target:action创建一个UIBarButtonItem对象,例如,
UIBarButtonItem *newBarButton = [[UIBarButtonItem alloc] initWithImage: yourImage
target: self
action: @selector(buttonPressed) ];
self.navigationItem.leftBarButtonItem = newBarButton;
[newBarButton release];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4209 次 |
| 最近记录: |