我在这里有一个BarButtonItem动画:
[UIView animateWithDuration:AnimDurationTintColorHint delay:0 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse animations:^{
[view performSelector:@selector(setTintColor:) withObject:UIColor.blackColor];
} completion:^(BOOL finished) {
........
}];
因为UIBarButtonItem没有图层属性,所以我无法使用.layer removeAllAnimations来停止分配的无限动画。
如何删除?
答案 0 :(得分:3)
您必须使用leftBarButtonItem或rightBarButtonItem,然后将UIBarButtonItem的enabled属性设置为NO。
UIImage *img = [UIImage imageNamed:@"your image"];
UIButton *btnMenu = [UIButton buttonWithType:UIButtonTypeCustom];
btnMenu.frame = CGRectMake( 10, 0, img.size.width, img.size.height);
[btnMenu addTarget:self action:@selector(handleBack:) forControlEvents:UIControlEventTouchUpInside];
[btnMenu setImage:img forState:UIControlStateNormal];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:btnMenu];
self.navigationItem.leftBarButtonItem = backButton;
self.navigationItem.leftBarButtonItem.enabled = NO;