UIBarButtonItem *right1 = [[UIBarButtonItemalloc]initWithTitle:@"1"
style:UIBarButtonItemStylePlain
target:self
action:@selector(Action:)];
[right1 setBackgroundImage:[UIImageimageNamed:@"right1.png"] forState:UIControlStateNormalbarMetrics:UIBarMetricsDefault];
right1.tag = 1;
UIBarButtonItem *right2 = [[UIBarButtonItemalloc]initWithTitle:@"2"
style:UIBarButtonItemStylePlain
target:self
action:@selector(Action:)];
[right1 setBackgroundImage:[UIImageimageNamed:@"right2.png"]
right2.tag = 2;
self.navigationItem.rightBarButtonItems = [NSArrayarrayWithObjects:right1,right2,nil];

本文介绍如何在 iOS 开发中使用 UIBarButtonItem 类创建自定义导航栏按钮,并设置按钮样式、背景图片及响应动作。

1万+

被折叠的 条评论
为什么被折叠?



