Hello @MarcoLopes,
Are you sure that branch does not execute? Is it possible there is something else in your app preventing that path of execution from being taken?
The following example works for me:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
if #available(iOS 17.0, visionOS 1.0, *) {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(button)
NSLayoutConstraint.activate([
button.centerXAnchor.constraint(equalTo: view.centerXAnchor),
button.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
button.setTitle("Hello", for: .normal)
button.hoverStyle = .init(effect: .automatic)
}
}
}