答案 0 :(得分:3)
这里的技巧是在导航栏中使用uibarbuttonitem的自定义视图。这个自定义视图有一个按钮:
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *backBtnImage = [UIImage imageNamed:@"btn-back"];
[backBtn setBackgroundImage:backBtnImage forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
backBtn.frame = CGRectMake(0, 0, 63, 33);
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 63, 33)];
[customView addSubview:backBtn];
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithCustomView:customView];
self.navigationItem.rightBarButtonItem = barButton;
然后,您可以为此自定义uiview设置动画。在按钮的动作中,您可以将框架设置得更大,然后在完成框架时再次将其设置为更小的动画。