我正在使用外观代理来设置 UIBarButtonItem 的背景图片:
UIImage *buttonBBI = [[UIImage imageNamed:@"bbi_texture.png"]
resizableImageWithCapInsets:UIEdgeInsetsMake(5, 4, 5, 4)];
这是bbi_texture@2x.png
(视网膜)
但是按钮中出现了一个白条。知道可能是什么原因造成的吗?
我正在使用外观代理来设置 UIBarButtonItem 的背景图片:
UIImage *buttonBBI = [[UIImage imageNamed:@"bbi_texture.png"]
resizableImageWithCapInsets:UIEdgeInsetsMake(5, 4, 5, 4)];
这是bbi_texture@2x.png
(视网膜)
但是按钮中出现了一个白条。知道可能是什么原因造成的吗?
这就是我制作自定义 UIBarButton 的方式。非常适合我。
UIButton *postView = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 61, 30)];
[postView setTitle:@"Post" forState:UIControlStateNormal];
[postView addTarget:self action:@selector(showAddPost) forControlEvents:UIControlEventTouchUpInside];
[postView setBackgroundImage:[UIImage imageNamed:@"bbi_texture.png"] forState:UIControlStateNormal];
[postView setBackgroundImage:[UIImage imageNamed:@"bbi_texture.png"] forState:UIControlStateHighlighted];
UIBarButtonItem *postButton = [[UIBarButtonItem alloc] initWithCustomView:postView];
[self.navigationItem setRightBarButtonItem:postButton];
希望下面的工作正常
UIBarButtonItem *homeButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"Home"] style:UIBarButtonItemStyleBordered target:nil action:@selector(goHome:)];
NSArray *leftBarButtonItems = [NSArray arrayWithObjects:homeButton,nil];
self.yourViewController.navigationItem.leftBarButtonItems = leftBarButtonItems;