从右向左移动按钮动画iOS-swift



我正在创建一个在视图控制器中带有一些按钮的应用程序。我想添加一个动画,就像所有按钮都是从右向左移动一样。但我所有的按钮都在从左向右移动。这是我的密码。

 override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        b1_center_alignment.constant -= self.view.bounds.width;
        b2_center_alignment.constant -= self.view.bounds.width;
        b3_center_alignment.constant -= self.view.bounds.width;
        b4_center_alignment.constant -= self.view.bounds.width;
        b5_center_alignment.constant -= self.view.bounds.width;
}
override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated);
        UIView.animateWithDuration(0.5, delay: 0.0, options: UIViewAnimationOptions.CurveEaseOut, animations: {
            self.b5_center_alignment.constant += self.view.bounds.width
            self.view.layoutIfNeeded()
            }, completion: nil)
        UIView.animateWithDuration(0.5, delay: 0.3, options: UIViewAnimationOptions.CurveEaseOut, animations: {
            self.b4_center_alignment.constant += self.view.bounds.width
            self.view.layoutIfNeeded()
            }, completion: nil)

        UIView.animateWithDuration(0.5, delay: 0.6, options: UIViewAnimationOptions.CurveEaseOut, animations: {
            self.b3_center_alignment.constant += self.view.bounds.width
            self.view.layoutIfNeeded()
            }, completion: nil)
        UIView.animateWithDuration(0.5, delay: 0.9, options: UIViewAnimationOptions.CurveEaseOut, animations: {
            self.b2_center_alignment.constant += self.view.bounds.width
            self.view.layoutIfNeeded()
            }, completion: nil)
        UIView.animateWithDuration(0.5, delay: 1.2, options: UIViewAnimationOptions.CurveEaseOut, animations: {
            self.b1_center_alignment.constant += self.view.bounds.width
            self.view.layoutIfNeeded()
            }, completion: nil);
    }

我是ios开发的新手。请有人帮我解决这个问题。这里CCD_ 1是来自CCD_ 2的中心水平约束。

进行时

b1_center_alignment.constant -= self.view.bounds.width;

你将按钮隐藏在屏幕左侧,然后使用

self.b5_center_alignment.constant += self.view.bounds.width

你把它移回原来的位置

你需要反转信号

b1_center_alignment.constant += self.view.bounds.width;

以及self.b5_centre_alignment.constant-=self.view.bounds.width

最新更新