Hi, 😊
I'm learning swift and I have issues with with functions containing the : button.title(for: .normal) == nil
so apparently since IOS 15 the code of the button is different
but I haven't being able to found the code snip to test ```
button.title(for: .normal) == nil
I'm also looking for the new way of writing button.setTitle(nil, for: .normal)
Anybody has a clue ?
Cheers
How is the new way to test button.title(for: .normal) == nil and since IOS 15
Could you show the code that does not work in iOS 16 ? And tell what you get, what you expect ?
Neither button.title(for: .normal) nor setTitle(nil, for: .normal) have neen obsoleted.
To use configuration, just do this:
var configuration = UIButton.Configuration.filled()
configuration.title = "Title" // Or nil here is you need
configuration.subtitle = "Subtitle"
configuration.image = UIImage(systemName: "swift")
let button = UIButton(configuration: configuration, primaryAction: nil)
Get sample code here: https://sarunw.com/posts/new-way-to-style-uibutton-in-ios15/
or here:
https://www.raywenderlich.com/27854768-uibutton-configuration-tutorial-getting-started
To set up depending on state resuires to write a handler:
https://sarunw.com/posts/dynamic-button-configuration/
To test title according to state:
let configuration = button.configuration
if button.state == .normal && configuration.title == nil { }