swift代码片段(代码片段)

author author     2023-01-19     453

关键词:

    func panGestureAction(_ panGesture: UIPanGestureRecognizer) 
        let translation = panGesture.translation(in: view)
        
        if panGesture.state == .began 
            originalPosition = view.center
            originalPositionNC = navigationController?.navigationBar.center
            currentPositionTouched = panGesture.location(in: view)
         else if panGesture.state == .changed 
            if (translation.y > 0)
                view.frame.origin = CGPoint(
                    x:  view.frame.origin.x,
                    y:  view.frame.origin.y + translation.y
                )
                self.navigationController?.navigationBar.frame.origin = CGPoint(
                    x: self.view.frame.origin.x,
                    y:  view.frame.origin.y + translation.y
                )
                panGesture.setTranslation(CGPoint.zero, in: self.view)
            
            
         else if panGesture.state == .ended 
            let velocity = panGesture.velocity(in: view)
            if velocity.y >= 150 
                UIView.animate(withDuration: 0.2
                    , animations: 
                        self.view.frame.origin = CGPoint(
                            x: self.view.frame.origin.x,
                            y: self.view.frame.size.height
                        )
                        self.navigationController?.navigationBar.frame.origin = CGPoint(
                            x: self.view.frame.origin.x,
                            y: self.view.frame.size.height
                        )
                , completion:  (isCompleted) in
                    if isCompleted 
                        self.dismiss(animated: false, completion: nil)
                    
                )
             else 
                UIView.animate(withDuration: 0.2, animations: 
                    self.view.center = self.originalPosition!
                    self.navigationController?.navigationBar.center = self.originalPositionNC
                )
            
        
    

swift代码审查(代码片段)

查看详情

swift和暦.swift(代码片段)

查看详情

swift用例.swift(代码片段)

查看详情

swift词性标记swift(代码片段)

查看详情

swift使用swift扩展(代码片段)

查看详情

swift布(代码片段)

查看详情

swift枚举(代码片段)

查看详情

swift只读(代码片段)

查看详情

swift存储(代码片段)

查看详情

swift操场(代码片段)

查看详情

swift排列(代码片段)

查看详情

swift选配(代码片段)

查看详情

swift阴影(代码片段)

查看详情

swift迅速(代码片段)

查看详情

swift枚举(代码片段)

查看详情

swift字典(代码片段)

查看详情

swift列举(代码片段)

查看详情

swift约束(代码片段)

查看详情