簡體   English   中英

如何在iOS上刪除UIBarButtonItem tintColor動畫?

[英]How to remove UIBarButtonItem tintColor animation on iOS?

我在這里有一個BarButtonItem動畫:

[UIView animateWithDuration:AnimDurationTintColorHint delay:0 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse animations:^{
    [view performSelector:@selector(setTintColor:) withObject:UIColor.blackColor];
} completion:^(BOOL finished) {
  ........
}];

因為UIBarButtonItem沒有layer屬性,所以我不能使用.layer removeAllAnimations來停止分配的無盡動畫。

如何刪除?

您必須使用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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM