在iOS中将图像设置为导航栏后退按钮

时间:2014-05-29 11:01:21

标签: ios iphone

如何在iOS中设置导航栏后退按钮的图像任何人都可以告诉我必须使用的图像的大小。

由于

3 个答案:

答案 0 :(得分:2)

UIImage* image3 = [UIImage imageNamed:@"back_button.png"];
CGRect frameimg = CGRectMake(15,5, 25,25);
UIButton *someButton = [[UIButton alloc] initWithFrame:frameimg];
[someButton setBackgroundImage:image3 forState:UIControlStateNormal];
[someButton addTarget:self action:@selector(Back_btn:)
     forControlEvents:UIControlEventTouchUpInside];
[someButton setShowsTouchWhenHighlighted:YES];
UIBarButtonItem *mailbutton =[[UIBarButtonItem alloc] initWithCustomView:someButton];
self.navigationItem.leftBarButtonItem =mailbutton;
[someButton release];

答案 1 :(得分:1)

如果您的应用针对iOS 7+并且您只想更改后退箭头,那么这可能是最快的解决方案:

self.navigationController.navigationBar.backIndicatorImage = [UIImage imageNamed:@"back.png"];
self.navigationController.navigationBar.backIndicatorTransitionMaskImage = [UIImage imageNamed:@"back.png"];

它取决于你的尺寸;虽然我不会比默认的背面图像小得多。

答案 2 :(得分:0)

将此用于您的要求...... self.navigationItem.backBarButtonItem = [UIBarButtonItem alloc] initWithImage:<#(UIImage *)#>式:其中#(UIBarButtonItemStyle)#>目标:其中#(ID)#>动作:其中#(SEL)#>