Code: Select all
func buttonImage() {
var configuration = UIButton.Configuration.plain()
configuration.image = UIImage(named: "someImage")!
configuration.baseBackgroundColor = .red
configuration.contentInsets = .zero
let button = UIButton(configuration: configuration)
button.backgroundColor = .red
button.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(button)
button.widthAnchor.constraint(equalToConstant: 300).isActive = true
button.heightAnchor.constraint(equalToConstant: 300).isActive = true
button.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
button.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
}
[img]https://i.sstatic.net /MPBRE3pB.png[/img]
Alles funktioniert gut, wenn ich eine Einzelskala mit 135x135 ohne @3x-Suffix anstelle von Einzelskalen mit 3 Bildern 45x45 verwende. 90x90, 135x135 in meinen Assets.
Wie kann ich das Problem mithilfe der Konfiguration beheben?