Reputation: 52
I have a view controller on which i have a button on right side named "EDIT", what i want to do is when user click on edit button then the button become hidden and a new button comes out at place of that button named "DONE". Here is code what i done so far -
import UIKit
class ViewController: UIViewController {
@IBOutlet var editBtn: UIButton!
@IBOutlet var doneBtn: UIButton!
@IBOutlet var welcomeBtn: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// action when user taps on welcome button
@IBAction func editBtnTapped(_ sender: Any) {
}
}
Upvotes: 1
Views: 52
Reputation: 270
Just change your code like this -
import UIKit
class ViewController: UIViewController {
@IBOutlet var editBtn: UIButton!
@IBOutlet var doneBtn: UIButton!
@IBOutlet var welcomeBtn: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
self.doneBtn.isHidden = true
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// action when user taps on welcome button
@IBAction func editBtnTapped(_ sender: Any) {
self.editBtn.isHidden = true
self.doneBtn.isHidden = false
}
@IBAction func doneBtnTapped(_ sender: Any) {
self.doneBtn.isHidden = true
self.editBtn.isHidden = false
}
}
Upvotes: 1