3

我正在尝试为 a 的图像设置动画UIButton。动画运行良好,但之后它总是在按钮上加上灰色调(好像它被突出显示/选中)。

代码:

NSArray *images = [[NSArray alloc] init];
images = [NSArray arrayWithObjects:
          [UIImage imageNamed:IMAGE1],
          [UIImage imageNamed:IMAGE2],
          [UIImage imageNamed:IMAGE3],
          [UIImage imageNamed:IMAGE4],
          nil];
iconBobble.imageView.animationImages = images;
iconBobble.imageView.animationDuration = 1.5;
iconBobble.imageView.animationRepeatCount = 1;
[iconBobble.imageView startAnimating];
4

2 回答 2

8

adjustsImageWhenHighlighted物业会解决你的问题。

此代码将解决您的问题....

-(IBAction)animateButton:(id)sender
{
    [iconBobble setAdjustsImageWhenHighlighted:NO];

    NSArray *images = [[NSArray alloc] init];
    images = [NSArray arrayWithObjects:
              [UIImage imageNamed:IMAGE1],
              [UIImage imageNamed:IMAGE2],
              [UIImage imageNamed:IMAGE3],
              [UIImage imageNamed:IMAGE4],
              nil];

    float animationDuration = 1.5;
    iconBobble.imageView.animationImages = images;
    iconBobble.imageView.animationDuration = animationDuration;
    iconBobble.imageView.animationRepeatCount = 1;
    [iconBobble.imageView startAnimating];
    [self performSelector:@selector(stopButtonAnimation) withObject:nil afterDelay:animationDuration];
}
-(void)stopButtonAnimation
{
    [iconBobble.imageView stopAnimating];
}

这对我来说很好:-)

于 2013-03-29T04:42:29.007 回答
0

yourButton.backgroundColor = [UIColor clearColor];

于 2013-03-29T03:59:14.583 回答