HomeiOS Developmentios - Tips on how to make UIButton.Configuration spotlight look match that...

ios – Tips on how to make UIButton.Configuration spotlight look match that of system buttons


I am modernizing my app and updating UIButtons to make use of UIButton.Configuration. I switched a system button to the default plain configuration model however was stunned to seek out the button spotlight state is barely noticeable. Whenever you faucet down on a conventional system button, its alpha decreases quite a bit to point it’s being pressed, so it’s straightforward to know whenever you launch the contact this button might be triggered. Sadly with the plain button configuration, the spotlight state is difficult to see as a result of the looks barely modifications. Is there a technique to make this spotlight behave like all the opposite buttons corresponding to UIBarButtonItems?

let oldButton = UIButton(sort: .system)
oldButton.setTitle("System Button", for: .regular)
oldButton.body = CGRect(x: 50, y: 100, width: 150, peak: 30)
view.addSubview(oldButton)

let newButton = UIButton(configuration: {
    var config = UIButton.Configuration.plain()
    config.title = "Plain Button"
    return config
}())
newButton.body = CGRect(x: 50, y: 150, width: 150, peak: 30)
view.addSubview(newButton)

That is the spotlight state of the system button:

enter image description here

That is the spotlight state of the plain button:

enter image description here

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments