fade between two UIButton images

后端 未结 8 982
醉酒成梦
醉酒成梦 2020-12-15 10:27

i want to fade between two UIButton images for the purpose of setting favorites in a UITableView.

Currently the transition is done without effect - it just changes t

8条回答
  •  醉酒成梦
    2020-12-15 11:07

    You could try to transition the alpha values like this to get the effect that you want:

    trans_img = [UIImage imageNamed:@"fav_on.png"];
    
    NSArray *subviews = [owningCell subviews];
    UIButton *favbutton = [subviews objectAtIndex:2];
    [UIView animateWithDuration:0.5 animations:^{
        favbutton.alpha = 0.0f;
    } completion:^(BOOL finished) {
        favbutton.imageView.animationImages = [NSArray arrayWithObjects:trans_img,nil];
        [favbutton.imageView startAnimating];
        [UIView animateWithDuration:0.5 animations:^{
            favbutton.alpha = 1.0f;
        }];
    }];
    

提交回复
热议问题