Home > database >  How to set UIBackgroundConfiguration for UIButton?
How to set UIBackgroundConfiguration for UIButton?

Time:10-14

I am struggling to change background properties of UIButton. They can be easily modified using "Background Configuration" settings in Interface Builder:

screenshot

but I don't understand how to set them programmatically.

For example, I try to do it like this:

UIBackgroundConfiguration * config = [UIBackgroundConfiguration listPlainCellConfiguration];
[config setStrokeColor: UIColor.labelColor];

but where should I assign this 'config' value? There is nothing like 'button.backgroundConfiguration' property or anything similar for UIButton object.

Note: 'configuration' property of UIButton object is not available in code (Objective C, Mac Catalyst, iOS 15) despite documentation statement, screenshot attached. Will be great to know the reason why this is so.

screenshot

CodePudding user response:

It happens that 'button.configuration.background' property is not available in the Xcode 13 beta 5 for Mac Catalyst.

One have to wait for newer Xcode release to get this feature working from code.

CodePudding user response:

The background is part of the UIButton.Configuration.

https://developer.apple.com/documentation/uikit/uibutton/configuration/3750780-background

  • Related