In the page below, there are a collection of themes displaying. When a user touches a theme, I want to show a green rectangle around it.
class ThemeCollectionViewCell: UICollectionViewCell {
...
@IBOutlet weak var rootStackView: UIStackView!
override var isSelected:Bool {
didSet {
if isSelected {
rootStackView.addBorders()
} else {
rootStackView.removeBorders()
}
}
}
}
In case there is an item (cell) to be selected by default, the selectItem() method should be called in the ViewController.viewDidAppear() method to take effect then the isSelected property of the selected cell will be set to true.
Here is an example of how to add the borders to a stack view.
No comments:
Post a Comment