以下尝试制作导航按钮并为其设置动画,但是我认为我遗漏了一些东西。
请让我知道我哪里出错了。
谢谢!这是在自定义 UINavigationItem 类中
-(void)awakeFromNib{
[super awakeFromNib];
UIImage *myimage = [UIImage imageNamed:@"navBarFilter.png"];
NSArray * imageArray = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"navBarFilter.png"],
[UIImage imageNamed:@"navBarFilter1.png"],
[UIImage imageNamed:@"navBarFilter2.png"],
[UIImage imageNamed:@"navBarFilter3.png"],
[UIImage imageNamed:@"navBarFilter4.png"],
[UIImage imageNamed:@"navBarFilter5.png"],
nil];
CGRect frameimg = CGRectMake(0, 0, myimage.size.width, myimage.size.height);
UIButton *someButton = [[UIButton alloc] initWithFrame:frameimg];
[someButton setBackgroundImage:myimage forState:UIControlStateNormal];
UIBarButtonItem *filterButton =[[UIBarButtonItem alloc] initWithCustomView:someButton];
someButton.imageView.animationImages =imageArray;
someButton.imageView.animationDuration=2.0;
someButton.imageView.contentMode=UIViewContentModeBottomLeft;
[someButton.imageView startAnimating];
self.rightBarButtonItem =filterButton;
}