2015-06-30 20 views

回答

0

你可以做的一件事!!!添加视图的姿态背后的观点,这种观点应该相同的姿势查看(甚至应该有相同的文字),以及识别手势之后一度带来-前的这一观点你的姿势查看它应该有旧的文本(不更新文本)和更新的姿态视图的文字的人它移动后面新增的观点,只是改变新添加视图的框架,以便它给出了一个滑动样的效果(改变其宽度)在完成动画之后将该视图带回到手势视图并将其框架更改为之前的先前值。

检查此示例:

func handleGesture(sender:UISwipeGestureRecognizer) { 
    //bring background view to front 
    self.view.bringSubviewToFront(self.backGroundView) 
    self.gestureView.userInteractionEnabled = false 

    //capture its initialAutolayout constraint 
    let backgroundViewSpaceConstarint = self.backGroundViewLeftSpaceConstraint.constant 
    UIView.animateWithDuration(2, animations: { [unowned self]() -> Void in 
     self.someRandomValue++ 

     // update text label in gesture view which is behind background View 
     self.gestureViewTextLabel.text = "swiped \(self.someRandomValue) times" 

     //slide backgroundView in required direction by using autolayout 
     self.backGroundViewLeftSpaceConstraint.constant = self.backGroundView.bounds.size.width 
     self.backGroundView.layoutIfNeeded() 
     }) { [unowned self](completion:Bool) -> Void in 
      //after animation complition bring gesture view to the front. 
      self.backgroundTextLabel.text = "swiped \(self.someRandomValue) times" 
      self.gestureView.userInteractionEnabled = true 

      //upadte background view so that it will look the same for next swipe 
      self.backGroundViewLeftSpaceConstraint.constant = backgroundViewSpaceConstarint 
      //send the background view behind gesture view 
      self.view.sendSubviewToBack(self.backGroundView) 
      } 
    }