HomeiOS Developmentios - Swift 5 UIKIT. I wish to make 2 buttons dynamic,...

ios – Swift 5 UIKIT. I wish to make 2 buttons dynamic, in order that when one is pressed, the opposite one shrinks and vice versa


I’ve 2 buttons. “Shares” one is default, it has bigger measurement and daring, the “Favorites” one is small. When the second is pressed, I would like “Shares” to vary measurement dynamically. I attempted to hardcode, however then realized viewDidLoad() is known as solely as soon as. How can I deal with this?

//MARK: – Shares Button and Favorites Button
stocksButton .setTitle(“Shares”, for: .regular)
activated(button: stocksButton)
favoritesButton .setTitle(“Favorites”, for: .regular)
disabled(button: favoritesButton)

    if favoritesButton.isSelected {
        disabled(button: stocksButton)
        activated(button: favoritesButton)
    }
    if (stocksButton.isSelected) {
        disabled(button: favoritesButton)
        activated(button: stocksButton)
    }
    func disabled(button: UIButton) {
        button.setTitleColor(.grey, for: .regular)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 18)
    }
    func activated(button: UIButton) {
        button.setTitleColor(.black, for: .regular)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 28)
    }

// that is in my viewDidLoad() operate

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments