Bạn xử lý animation trong iOS như thế nào bằng UIView.animate?
Bạn xử lý animation trong iOS như thế nào bằng UIView.animate?
UIView.animate tạo hoạt ảnh bằng cách thay đổi thuộc tính animatable (alpha, frame, transform, backgroundColor, constraint constant sau layoutIfNeeded).
// Cơ bản
UIView.animate(withDuration: 0.3, delay: 0, options: [.curveEaseInOut]) {
self.box.alpha = 0.5
self.box.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
} completion: { finished in
print("xong")
}
// Spring
UIView.animate(withDuration: 0.6, delay: 0, usingSpringWithDamping: 0.7,
initialSpringVelocity: 0.5, options: []) {
self.card.center.y -= 100
}
// Animate Auto Layout
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.