拓展:
extension UIView {
public func setScale(x: CGFloat, y: CGFloat) {
var transform = CATransform3DIdentity
transform.m34 = 1.0 / -1000.0
transform = CATransform3DScale(transform, x, y, 1)
self.layer.transform = transform
}
}
使用:
// 底部弹窗
botFloatView?.setScale(x: 0, y: 0)
botFloatView?.isHidden = false
UIView.animate(withDuration: 0.4) { [weak self] in
self?.botFloatView?.setScale(x: 1, y: 1)
} completion: { _ in
DispatchQueue.main.asyncAfter(deadline: .now() + TimeInterval(2)) { [weak self] in
UIView.animate(withDuration: 0.4) { [weak self] in
self?.botFloatView?.setScale(x: 0.1, y: 0.1)
} completion: { [weak self] _ in
self?.botFloatView?.isHidden = true
}
}
}
示意: