2015-08-25 131 views
0

我想將此View基於動畫轉換爲基於Layer的基礎。iOS8:查看圖層動畫

@IBOutlet weak var constraintTopContainerHeight: NSLayoutConstraint! 

override func viewDidLoad() { 
    super.viewDidLoad() 

    var value:CGFloat 

    switch (someTag) 
    { 
    case 1: 
     value = CGFloat(self.view.bounds.height/3) 
    case 2: 
     value = CGFloat(self.view.bounds.height/2) 
    case 3: 
     value = CGFloat(self.view.bounds.height * 0.8) 
    default: 
     value = 0.0 
    } 

    UIView.animateWithDuration(1.5, delay: 0.0, 
     usingSpringWithDamping: 0.3, initialSpringVelocity: 0.0, 
     options: nil, animations: { 

     self.constraintTopContainerHeight.constant = value 
     self.view.layoutIfNeeded() 

     }, completion: nil) 
    } 
} 

我如何獲得一個Constraint使用Layer基於動畫而不是當前View基於動畫。代碼請。

回答