M-Learning M-Learning - 2 months ago 38
Swift Question

how i can add animation to any UI by snapkit by swift 3?

label.snp.makeConstraints { (make) -> Void in

make.width.equalTo(box).dividedBy(2)

make.top.equalTo(100)

make.left.greaterThanOrEqualTo(box.snp.left).offset(15)
}


I want animate this
label
to another position by
button

Answer

After you update your constraints call layoutIfNeeded() on your view in an animation closure.

    UIView.animateWithDuration(0.2, delay: 0, options: [], animations: { () -> Void in 
       self.view.layoutIfNeeded()
    })

Hope this helps.

Comments