美文网首页
收藏按钮的点击效果

收藏按钮的点击效果

作者: 醉梦年华笑沧桑 | 来源:发表于2017-12-20 11:27 被阅读0次

    先建个结构体属性: 

    {int i; UIButton *button;} 

    创建个按钮:

    button= [[UIButton alloc] initWithFrame:CGRectMake(100,300,20,20)];

    [button setImage:[UIImage imageNamed:@"收藏Normal"] forState:UIControlStateNormal];

    [button setImage:[UIImage imageNamed:@"收藏Selected"] forState:UIControlStateSelected];

    [button addTarget:self action:@selector(change:) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:button];

    实现方法:

    -(void)change:(UIButton*)sender {

    [button setImage:[UIImage imageNamed:(i%2==0?@"收藏Selected":@"收藏Normal")]forState:UIControlStateNormal];

    CAKeyframeAnimation *k = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];

    k.values=@[@(0.1),@(1.0),@(1.5)];

    k.keyTimes=@[@(0.0),@(0.5),@(0.8),@(1.0)];

    k.calculationMode=kCAAnimationLinear;

    i++;

    [button.layer addAnimation:kforKey:@"SHOW"];

    }

    OK。

    相关文章

      网友评论

          本文标题:收藏按钮的点击效果

          本文链接:https://www.haomeiwen.com/subject/nztgwxtx.html