@@ -39,8 +39,9 @@ class DetailViewController: UIViewController {
3939
4040 let btn = UIButton ( type: . custom)
4141 btn. setBackgroundImage ( UIImage ( named: " btn_close " ) , for: . normal)
42- btn. frame = CGRect ( x: UIScreen . main. bounds. width - 50 , y: 30 , width: 40 , height: 40 )
42+ btn. frame = CGRect ( x: UIScreen . main. bounds. width - 50 , y: 30 , width: 30 , height: 30 )
4343 btn. addTarget ( self , action: #selector( closeAction ( _: ) ) , for: . touchUpInside)
44+ btn. tag = 99
4445 view. addSubview ( btn)
4546
4647 panGesture = UIPanGestureRecognizer ( target: self , action: #selector( panAction ( _: ) ) )
@@ -58,33 +59,49 @@ class DetailViewController: UIViewController {
5859// }
5960
6061 @objc private func closeAction( _ btn: UIButton ) {
61- self . table . setContentOffset ( CGPoint ( x : 0 , y : 0 ) , animated : true )
62+
6263 self . navigationController? . popViewController ( animated: true )
6364 }
6465
6566 @objc func panAction( _ pan: UIPanGestureRecognizer ) {
6667
6768 var scale = percentForGesture ( pan)
68- print ( scale)
69+ // print(scale)
6970
7071 switch pan. state {
7172 case . possible, . began:
73+ // self.navigationController?.delegate = self.navTransition
74+ // self.navTransition.gesture = panGesture
7275 break
7376 case . changed:
7477
75- if scale > 0.85 {
76- self . view. transform = CGAffineTransform ( scaleX: scale, y: scale)
78+ let btn = view. viewWithTag ( 99 )
79+
80+ if scale >= 0.85 {
81+ self . table. transform = CGAffineTransform ( scaleX: scale, y: scale)
82+
83+ btn? . alpha = 1 - ( 1 - scale) * 1 / 0.15
84+
85+ self . table. layer. masksToBounds = true
86+ self . table. layer. cornerRadius = ( 1 - scale) * 10 / 0.15
87+
7788 } else {
7889 scale = 0.85
7990 self . navigationController? . popViewController ( animated: true )
80- self . view. transform = CGAffineTransform . identity
91+ self . table. transform = CGAffineTransform . identity
92+ btn? . alpha = 0
93+ btn? . removeFromSuperview ( )
94+
8195 }
8296
8397 break
8498
8599 case . cancelled, . ended, . failed:
86100 UIView . animate ( withDuration: 0.3 ) {
87101 self . table. transform = CGAffineTransform . identity
102+ let btn = self . view. viewWithTag ( 99 )
103+
104+ btn? . alpha = 1
88105 }
89106 }
90107
@@ -128,7 +145,7 @@ extension DetailViewController: UITableViewDelegate, UITableViewDataSource {
128145 }
129146
130147 func tableView( _ tableView: UITableView , didSelectRowAt indexPath: IndexPath ) {
131- self . navigationController? . popViewController ( animated: true )
148+ // self.navigationController?.popViewController(animated: true)
132149 }
133150
134151}
0 commit comments