How to do a native “Pulse effect” animation on a UIButton - iOS

前端 未结 4 780
梦如初夏
梦如初夏 2020-12-02 04:28

I would like to have some kind of pulse animation (infinite loop \"scale in - scale out\") on a UIButton so it gets users\' attention immediately.

I saw this link Ho

4条回答
  •  佛祖请我去吃肉
    2020-12-02 04:48

    func animationScaleEffect(view:UIView,animationTime:Float)
    {
        UIView.animateWithDuration(NSTimeInterval(animationTime), animations: {
    
            view.transform = CGAffineTransformMakeScale(0.6, 0.6)
    
            },completion:{completion in
                UIView.animateWithDuration(NSTimeInterval(animationTime), animations: { () -> Void in
    
                    view.transform = CGAffineTransformMakeScale(1, 1)
                })
        })
    
    }
    
    
    @IBOutlet weak var perform: UIButton!
    
    @IBAction func prefo(sender: AnyObject) {
        self.animationScaleEffect(perform, animationTime: 0.7)
    }
    

提交回复
热议问题