UIView幻灯片动画

时间:2015-02-04 17:04:34

标签: ios swift uiview core-animation

我正在尝试创建动画以使用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)
    }
}

enter image description here

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

为此你可以使用iCarousel库非常强大,易于集成,你有很多动画。 你也可以使用HGPageScrollView,这是一个非常好的图书馆

希望有所帮助