我正在尝试使用外观方法(>iOS 5.0)自定义UIBarButtonItem。它适用于UIControlStateNormal,但不适用于高亮显示或禁用。查看图片
以下是我用来设置这些的代码:
// now configure the UIBarButtonItems
UIImage *buttonBGInactive = [[UIImage imageNamed:@"button-navbar-30-inactive.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)];
UIImage *buttonBGActive = [[UIImage imageNamed:@"button-navbar-30-pressed.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)];
[[UIBarButtonItem appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setBackgroundImage: buttonBGInactive forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setBackgroundImage: buttonBGActive forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
有什么想法吗?图片本身是30x30px,我不需要横向模式。