I am creating an application with some buttons in a view controller. I want to add one animation like all the buttons are move from right to left. But all my buttons are moving from left to right. Here is my code.
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);
}
I am very new to ios development. Please someone help me to solve this issue. Here b1_center_alignment, b2_center_alignment
are center horizontal constraints from storyboard
.