UIView animation options using Swift

后端 未结 3 1438
傲寒
傲寒 2021-01-31 02:17

How do I set the UIViewAnimationOptions to .Repeat in an UIView animation block:

UIView.animateWithDuration(0.2, delay:0.2         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-31 03:03

    Swift 3

    Pretty much the same as before:

    UIView.animate(withDuration: 0.2, delay: 0.2, options: UIViewAnimationOptions.repeat, animations: {}, completion: nil)
    

    except that you can leave out the full type:

    UIView.animate(withDuration: 0.2, delay: 0.2, options: .repeat, animations: {}, completion: nil)
    

    and you can still combine options:

    UIView.animate(withDuration: 0.2, delay: 0.2, options: [.repeat, .curveEaseInOut], animations: {}, completion: nil)
    

    Swift 2

    UIView.animateWithDuration(0.2, delay: 0.2, options: UIViewAnimationOptions.Repeat, animations: {}, completion: nil)
    
    UIView.animateWithDuration(0.2, delay: 0.2, options: .Repeat, animations: {}, completion: nil)
    
    UIView.animateWithDuration(0.2, delay: 0.2, options: [.Repeat, .CurveEaseInOut], animations: {}, completion: nil)
    

提交回复
热议问题