顶部菜单弹出动画

This commit is contained in:
bluesea 2024-04-30 18:06:12 +08:00
parent 8d7aecad87
commit f89962cae9

View File

@ -259,9 +259,10 @@ public class CCSpatialDisplayTypeView: UIView {
tableView.bounces = false
tableView.showsVerticalScrollIndicator = false
tableView.isScrollEnabled = false
UIView.animate(withDuration: 0.3) {[weak self] in
self?.addSubview((self?.tableView)!)
}
self.addSubview(self.tableView)
// UIView.animate(withDuration: 0.3) {[weak self] in
//
// }
//
showBottomView.frame = CGRect(x: self.tableView.left, y: self.tableView.bottom + 8, width: self.tableView.width, height: 40)
@ -343,9 +344,42 @@ extension CCSpatialDisplayTypeView{
return
}
initViews()
// let height = tableView.height
// tableView.height = 0
let frame = self.tableView.frame;
self.tableView.layer.anchorPoint = CGPointMake(0.5, 0)
self.tableView.frame = frame
// zoomInAnimation(view: self.tableView, scale: 0, duration: 0, delay: 0)
UIApplication.shared.keyWindow?.addSubview(self)
// UIView.animate(withDuration: 0.25) {[weak self] in
// self?.tableView.height = height
// } completion: { finish in
//
// }
zoomInAnimation(view: self.tableView, scale: 1, duration: 0.25, delay: 0)
}
func zoomInAnimation(view: UIView, scale: CGFloat, duration: TimeInterval, delay: TimeInterval) {
//
let scaleAnimation = CABasicAnimation(keyPath: "transform.scale")
scaleAnimation.toValue = scale
scaleAnimation.fromValue = 0.0
scaleAnimation.duration = duration
scaleAnimation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
scaleAnimation.fillMode = .forwards
scaleAnimation.isRemovedOnCompletion = false
//
UIView.animate(withDuration: duration, delay: delay, options: [], animations: {
view.layer.add(scaleAnimation, forKey: "zoomInAnimation")
}, completion: nil)
}
public func dismiss() {
isShowing = false
self.dissMissCallback()