Joe Simpson
Joe Simpson

Reputation: 2594

UIVisualEffectView and touches inside UITableViewCell

I'm having an issue with using a UIVisualEffectView inside a custom UITableViewCell.

When the table cell is touched, the effect view seems to be switching Vibrancy on by itself which isn't the desired effect I'm after at all. Vibrancy also seems to keep itself switched on even after navigating to another view and back again.

Upvotes: 0

Views: 105

Answers (1)

Kamil Harasimowicz
Kamil Harasimowicz

Reputation: 4994

OK. I think I found solution. The problem is with default selection of UITableViewCell. I think you code looks familiar to this:

class CustomTableViewCell: UITableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()

        selectedBackgroundView = UIView(frame: CGRect(x: -1, y: -1, width: 1, height: 1))
        selectedBackgroundView?.backgroundColor = .clear
    }
}

and the effect is http://pl.tinypic.com/player.php?v=o00z1k&s=9#.WOpT5VLUTMU

but a small change a code:

class CustomTableViewCell: UITableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()

        selectionStyle = .none
    }
}

and vibrancy effect will disappear.

Note, you can set it via storyboard

enter image description here

Upvotes: 1

Related Questions