有关导航栏的相关认识
1、在导航栏上添加按钮,又两个属性:
navigationItem.rightBarButtonItem和navigationItem.leftBarButtonItem
2、默认情况下,导航栏上的左右按钮只能设置一张图片,要想设置普通和高亮的图片,徐自定义按钮,将按钮传给navigationItem
具体实现的代码如下事例:
UIButton * leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
[leftButton setBackgroundImage:[UIImage imageWithNamed:@"navigationbar_friendsearch"] forState:UIControlStateNormal];
[leftButton setBackgroundImage:[UIImage imageNamed:@"navigationbar_friendsearch_highlighted"] forState:UIControlStateHighlighted];
leftButton.frame = (CGRect){CGPointZero,leftButton.currentBackgroundImage.size};
[leftButton addTarget:self action:@selector(findFriend) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:leftButton];