为 BarButton 创建推送动画
Created Pushed Animation for BarButton
在视图控制器上,我有一个通过此代码自定义图像的后退按钮
UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
[backButton setImage:[UIImage imageNamed:@"left207.png"] forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(goToParent) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backBtn = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = backBtn;
self.navigationItem.rightBarButtonItem = rightButton;
但是当我运行这个app的时候,没有推送那种效果。一秒也不会变黑
您需要为高亮状态设置另一张图片:
[backButton setImage:[UIImage imageNamed:@"highlightedButton"] forState:UIControlStateHighlighted];
在视图控制器上,我有一个通过此代码自定义图像的后退按钮
UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
[backButton setImage:[UIImage imageNamed:@"left207.png"] forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(goToParent) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backBtn = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = backBtn;
self.navigationItem.rightBarButtonItem = rightButton;
但是当我运行这个app的时候,没有推送那种效果。一秒也不会变黑
您需要为高亮状态设置另一张图片:
[backButton setImage:[UIImage imageNamed:@"highlightedButton"] forState:UIControlStateHighlighted];