Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide elements in a Stack View

I have 4 separate views and I want to hide the other 3 of them when one of the buttons is pressed.

I have them in a UIStackView but .isHidden = true does not hide the views for some reason.

It works fine when they're not in a stack view.

@IBAction func qbpressed(_ sender: Any) {
    QBContainer.isHidden = false
    WRContainer.isHidden = true
    RBContainer.isHidden = true
    QBIndicator.isHidden = false
    WRIndicator.isHidden = true
    RBIndicator.isHidden = true
    TEIndicator.isHidden = true
    QBButton.setTitleColor(#colorLiteral(red: 0, green: 0.5008062124, blue: 1, alpha: 1), for: .normal)
    WRButton.setTitleColor(#colorLiteral(red: 0.7540688515, green: 0.7540867925, blue: 0.7540771365, alpha: 1), for: .normal)
    RBButton.setTitleColor(#colorLiteral(red: 0.7540688515, green: 0.7540867925, blue: 0.7540771365, alpha: 1), for: .normal)
    TEButton.setTitleColor(#colorLiteral(red: 0.7540688515, green: 0.7540867925, blue: 0.7540771365, alpha: 1), for: .normal)

    if intersitial.isReady{
        intersitial.present(fromRootViewController: self)
    } 
}

stack view

like image 472
Noah Iarrobino Avatar asked Aug 13 '18 20:08

Noah Iarrobino


People also ask

What is Uistackview?

A streamlined interface for laying out a collection of views in either a column or a row.

How do I delete a stack view?

In order to delete a Stack View, two methods: (A) (1) open the navigator then the outline view; (2) select the Stack View that we want to delete/remove (see select the Stack View); (3) In the top Xcode tool banner click Editor then Unembed.


1 Answers

isHidden property doesn't work, but you can use alpha and achieve the same result,

QBIndicator.alpha = 1.0 will work for QBIndicator.isHidden = false and QBIndicator.alpha = 0.0 will work for QBIndicator.isHidden = true

like image 94
Noah Iarrobino Avatar answered Sep 27 '22 21:09

Noah Iarrobino