I'm trying to add a button to UIVisualEffectView. However, the button that I add is not responding to touch events and I don't understand why. This is the code.
override func viewDidLoad() {
super.viewDidLoad()
let image = UIImage(named: "face2")
let imageView = UIImageView(image: image)
imageView.frame = CGRectMake(0, 0, 200, 200)
let button = UIButton(frame: CGRectMake(50, 50, 100, 100))
button.setTitle("huhuhu", forState: UIControlState.Normal)
button.setTitleColor(UIColor.blackColor(), forState: .Normal)
button.userInteractionEnabled = true
let effect = UIBlurEffect(style: .Light)
let blurView = UIVisualEffectView(effect: effect)
blurView.frame = view.bounds
view.addSubview(imageView)
view.addSubview(blurView)
view.addSubview(button)
}
Aucun commentaire:
Enregistrer un commentaire