0

我想在 IOS 7.0 中添加导航栏,并在其上添加栏按钮项。所以请建议如何在IOS应用程序中添加导航栏。

UIButton *btnBack=[UIButton buttonWithType:UIButtonTypeCustom];
[btnBack setImage:[UIImage imageNamed:@"aerrow-previous.png"] forState:UIControlStateNormal];
[btnBack setImage:[UIImage imageNamed:@"aerrow-previous.png"] forState:UIControlStateSelected];
[btnBack setTintColor:[UIColor clearColor]];
[btnBack setFrame:CGRectMake(5, 5, 20, 21)];
[btnBack addTarget:self action:@selector(backBtnPressed:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *leftBarButton=[[UIBarButtonItem alloc]initWithCustomView:btnBack];
[self.navigationItem setLeftBarButtonItem:leftBarButton];
btnBack = nil;
leftBarButton = nil;
// Add back button on navigation bar


UILabel *titileview=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 150, 44)];


[titileview setTextColor:[UIColor colorWithRed:(87.0f/255.0f) green:(87.0f/255.0f) blue:(87.0f/255.0f) alpha:1.0f]];
[titileview setText:@"SIGN IN"];
[titileview setTextAlignment:NSTextAlignmentCenter];
[titileview setBackgroundColor:[UIColor clearColor]];
[self.navigationItem setTitleView:titileview];
titileview = nil;
4

1 回答 1

0

您可以使用与此类似的代码:

UIBarButtonItem *addBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addObject:)];
[self.navigationItem setRightBarButtonItem:rightButton];

希望能帮助到你!

于 2013-10-01T17:27:47.717 回答