Iphone 导航栏中的信息灯按钮

Iphone 导航栏中的信息灯按钮,iphone,ios,uibutton,uinavigationbar,Iphone,Ios,Uibutton,Uinavigationbar,如何更改此代码,以便在导航栏的右角有一个信息按钮而不是一个单词 - (void)viewDidLoad { [self setTitle:@"About"]; [super viewDidLoad]; UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"info", @"")

如何更改此代码,以便在导航栏的右角有一个信息按钮而不是一个单词

- (void)viewDidLoad {
   [self setTitle:@"About"];
   [super viewDidLoad];
   UIBarButtonItem *addButton = [[[UIBarButtonItem alloc]   initWithTitle:NSLocalizedString(@"info", @"")
                                                            style:UIBarButtonItemStyleBordered
                                                            target:self
                                                            action:@selector(addAction:)] autorelease];
   self.navigationItem.rightBarButtonItem = addButton;  
}

这个问题经常被问到

        UIImage *buttonImage = [UIImage imageNamed:@"UIButtonInformationIcon.jpg"]; 
        //create the button and assign the image
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setImage:buttonImage forState:UIControlStateNormal];
        //set the frame of the button to the size of the image
        button.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);

        [button addTarget:self action:@selector(anyActionYouWant) forControlEvents:UIControlEventTouchUpInside]; 
        //create a UIBarButtonItem with the button as a custom view

        self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:button]autorelease];  

以下是几种解决方案中的一种。

或者。。。在将按钮添加到标题栏时,可以从下拉列表中选择所需的按钮类型。您需要选择“信息灯”类型