I have a question about the sizing for UIImage in UIbutton.
I'm trying to make a UIButton with SF symbols (xmark.circle) to add a dismissal or close button to my app and make it bigger. the icon is like this ...
To resize the SF symbols, I saw one developer uses withConfiguration and make the UIimage larger, and I checked it works in my project.
lazy var dismissButton: UIButton = {
let button = UIButton()
let large = UIImage.SymbolConfiguration(pointSize: 32, weight: .regular, scale: .default)
let largeImg = UIImage(systemName: "xmark.circle", withConfiguration: large)
button.isUserInteractionEnabled = true
button.setImage(largeImg, for: .normal)
button.tintColor = .lightGray
return button
}()
However, I already have a struct for UIimage and since I did not add withConfiguration
, I tried to add the withConfiguration when I create a button in code.
I mean, I have the Images struct
struct Images {
static let minus = UIImage(systemName: "minus")
static let trash = UIImage(systemName: "trash")
static let pencil = UIImage(systemName: "pencil")
static let xmarkCircle = UIImage(systemName: "xmark.circle")
// with more images...
}
and I want to call the Images struct when I create a button
lazy var dismissButton: UIButton = {
let button = UIButton()
button.isUserInteractionEnabled = true
button.setImage(Images.xmarkCircle, for: .normal) // -> like in here
button.tintColor = .lightGray
return button
}()
But in this case, since I just call the icon, Images.xmarkCircle, in setImage, I cannot assign withConfiguration to that icon. Probably, I can change Images.xmarkCircle to UIImage with configuration or something, but I don't want to make one of the icons in images struct has withConfiguration value.
So, is it possible to add withConfiguration when I make a button in lazy var dismissButton, or is there another way to resize the SFsymbol in code?