1 + (UIBarButtonItem *)itemWithIcon:(NSString *)icon highIcon:(NSString *)highIcon target:(id)target action:(SEL)action
2 {
3 UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
4 [button setBackgroundImage:[UIImage imageWithName:icon] forState:UIControlStateNormal];
5 [button setBackgroundImage:[UIImage imageWithName:highIcon] forState:UIControlStateHighlighted];
6 button.frame = (CGRect){CGPointZero, button.currentBackgroundImage.size};
7 [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
8 return [[UIBarButtonItem alloc] initWithCustomView:button];
9 }