UIButton Highlighted State not showing when clicking over a Selected UIButton
In swift
this would be:
button.setBackgroundImage(shadowImage, forState: UIControlState.Selected.union(UIControlState.Highlighted))
In Swift v3 (Nov. 2016):
button.setBackgroundImage(shadowImage, for: UIControlState.selected.union(UIControlState.highlighted))
The various states: UIControlStateNormal
, UIControlStateSelected
, and (UIControlStateSelected | UIControlStateHighlighted)
are all actually distinct. If you want your shadowImage
to apply both in the (only) highlighted state and in the highlighted+selected state, you must also set:
[button setBackgroundImage:shadowImage forState:(UIControlStateHighlighted | UIControlStateSelected)]