[Swift]: Concentration_Current Progress_1

swift

04/16/2019


Extra functionality implemented

Created two buttons to show all cards / hide all cards

SWIFT
// For debugging purposes
@IBAction func showCards(_ sender: UIButton) {
for index in cardButtons.indices {
let button = cardButtons[index]
let card = game.cards[index]
if !card.isMatched {
button.setTitle(emoji(for: card), for: UIControl.State.normal)
button.backgroundColor = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
}
}
}
@IBAction func hideCards(_ sender: UIButton) {
for index in cardButtons.indices {
let button = cardButtons[index]
let card = game.cards[index]
if !card.isMatched, index != curIndex {
button.setTitle("", for: UIControl.State.normal)
button.backgroundColor = card.isMatched ? #colorLiteral(red: 0.9254940748, green: 0.1921561658, blue: 0.3890609741, alpha: 0) : #colorLiteral(red: 1, green: 0.5763723254, blue: 0, alpha: 1)
}
}
}

WRITTEN BY

Keeping a record