All I want to do is keep a button hidden until another button is pressed.
For example, Button 1 is visible, but Button 2 isn't. When I press Button 1, I need Button 2 to appear.
Also, I am programming in Xcode 6 using Swift.
Thanks in advance!
Just create an IBOutlet of the same button and set its isHidden property to true once it's tapped. Save this answer.
Use an opacity(_:) modifier with a value of 0 so that the layout accounts for the error message whether or not it's visible. You can also use this strategy for removing a view that doesn't affect other views' placement, like a view inside an overlay(alignment:content:) modifier.
hidden = YES; // or view. hidden = NO; or by calling setHidden: [view setHidden:YES]; // or [view setHidden:NO];
The sample code for hiding a button in Swift:
import UIKit
class ViewController: UIViewController {
// Create outlet for both the button
@IBOutlet weak var button1: UIButton!
@IBOutlet weak var button2: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
//Set button2 hidden at start
button2.hidden = true
}
//Here is the action when you press button1 which is visible
@IBAction func button1(sender: AnyObject) {
//Make button2 Visible
button2.hidden = false
}
}
May be this can help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With