我正在尝试创建动画以使用UIView
交换/旋转UIPanGestureRecognizer
。我有三个UIView
s并且想要添加动画以在拖动时将左视图或右视图带到前面。如果用户将前视图拖动到右侧,则左视图应该带有动画来到前面。以下是我在横向模式下生成UIView
的代码。
import UIKit
class ViewController: UIViewController {
var viewRight: UIView!
var viewFront: UIView!
var viewLeft: UIView!
var button: UIButton!
override func viewDidLoad() { }
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewDidAppear(animated: Bool) {
viewFront = UIView(frame: CGRectMake(0, 0, 200, 200))
viewFront.center = view.center
viewFront.backgroundColor = UIColor.redColor()
view.addSubview(viewFront)
viewLeft = UIView(frame: CGRectMake(0, 0, 200, 150))
viewLeft.center = view.center
viewLeft.center.x = view.center.x - 100
viewLeft.backgroundColor = UIColor.greenColor()
view.addSubview(viewLeft)
viewRight = UIView(frame: CGRectMake(0, 0, 200, 150))
viewRight.center = view.center
viewRight.center.x = view.center.x + 100
viewRight.backgroundColor = UIColor.blueColor()
view.addSubview(viewRight)
view.bringSubviewToFront(viewFront)
}
}
任何帮助将不胜感激!