如何在所有使用自定义 UINavigationBar 的界面中使用自定义 UIBarButtonItem
没有在每个界面都写一遍。
统一设置有统一的方法吗?
UIImage image = [UIImage imageNamed:imagePath];
UIButton button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
[button setImage:image forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:highLightImagePath] forState:UIControlStateHighlighted];
[button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
很多界面backBarButtonItem需要自定义,代码都一样,不想写N遍