JAB6240 JAB6240 - 2 years ago 126
Swift Question

UIButton does not change its alpha while being pushed

I am programming a game with a end screen. It's a view with a UIImageView on it.

The imageView has a UIVisualEffectView additionaly.

There is a button on my end screen (No, it's not part of the imageView).

If you touch it, it won't change it's alpha, like usual.

Answer Source

All you have to do is to initialize your button with UIButton(type:) and .System as type. Something like this:

var button = UIButton(type: .System)

If you don't use this, your button will not change it's alpha while being pushed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download