I have 2 buttons in header on CollectionViewController. When i tap on one of them i'm changing an image of this buttons using UIControlState -> .normal .selected.
override func viewDidLoad() {
super.viewDidLoad()
collectionView.delegate = self
collectionView.dataSource = self
engSwitchButton.setImage(#imageLiteral(resourceName: "abc"), for: .normal)
geoSwitchButton.setImage(#imageLiteral(resourceName: "abg"), for: .normal)
engSwitchButton.setImage(#imageLiteral(resourceName: "abc2"),for: UIControlState.selected)
geoSwitchButton.setImage(#imageLiteral(resourceName: "abg2"), for: UIControlState.selected)
engSwitchButton.tag = Language.english.rawInt
geoSwitchButton.tag = Language.georgian.rawInt
}
@IBAction func languageSwitchTapped(_ sender: UIButton) {
sender.isSelected = !sender.isSelected
selectedLanguage = Language(rawInt: sender.tag)!
collectionView.reloadData()
}
I want the button which i tapped first, get back to .normal state when i'm changing state of 2d button with tapping on it.