I want to add animation to these two views.
- Red
UIView
- Green
UIView
From the picture I want to add an animation when click on these two views.
First start with hide red UIView
.
Action : 1
when i click on green view i want green uiview silde to the right side until it disappear
and the red UIView
will slide out from the right side immediately.
red uiview slide from right side
and stopp when it is at that point in the storyboard and hide green UIView
.
Action : 2
and when i click on red view i want it to slide right until it disappears. Show green UIView
and comes out from the right corner as well and hide red UIView
.
My Code
import UIKit
class TestViewCell: UICollectionViewCell {
@IBOutlet weak var bgView: UIView!
@IBOutlet weak var bgAlertView: UIView!
@IBOutlet weak var imgAlert: UIImageView!
@IBOutlet weak var bgAlreadyAlertView: UIView!
@IBOutlet weak var imgAlreadyAlert: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
//Make an action when tap on bgAlertView
let actionBgAlert : Selector = #selector(self.actionBgAlert)
let viewPostsViewGesture = UITapGestureRecognizer(target: self, action: actionBgAlert)
bgAlertView.isUserInteractionEnabled = true
bgAlertView.addGestureRecognizer(viewPostsViewGesture)
//Make an action when tap on bgAlreadyAlertView
let actionBgAlreadyAlert : Selector = #selector(self.actionBgAlreadyAlert)
let viewAlreadyViewGesture = UITapGestureRecognizer(target: self, action: actionBgAlreadyAlert)
bgAlreadyAlertView.isUserInteractionEnabled = true
bgAlreadyAlertView.addGestureRecognizer(viewAlreadyViewGesture)
}
//action1
@objc func actionBgAlert(sender: UITapGestureRecognizer){
if imgAlert.image == #imageLiteral(resourceName: "alarm") {
self.bgAlertView.isHidden = true
self.bgAlreadyAlertView.isHidden = false
}
//action2
@objc func actionBgAlreadyAlert(sender: UITapGestureRecognizer){
if imgAlreadyAlert.image == #imageLiteral(resourceName: "alarmedMain") {
self.bgAlertView.isHidden = false
self.bgAlreadyAlertView.isHidden = true
}
}