0

Swift 5, XCode 12.0 Could you help me please pin the image to the right side of the button, which is located in UITableView (storyboard)

I tried following code, but it doesn't help:

@IBOutlet weak var testnet: UIButton!
---------------
testnet.setImage(UIImage(systemName: "checkmark"), for: .normal)
testnet.configuration?.imagePlacement = .trailing
testnet.configuration?.background.imageContentMode = .right
testnet.semanticContentAttribute = .forceRightToLeft

Here what I've got:

Here is constraints configuration: enter image description here

I tried to see button configuration, print() below enter image description here

  • Did you verify that the `configuration` property is non-nil? – Rob C Mar 28 '22 at 22:58
  • I don't think it's possible to add flexible offset to `UIButton` image. Usually such UI is [done](https://stackoverflow.com/q/5959950/3585796) using cell accessory, for a custom image you [can use](https://stackoverflow.com/a/10209080/3585796) accessory view. – Phil Dukhov Mar 29 '22 at 05:02
  • Have you given constraints to the button? if not please give leading and trailing constraints. – Pranay Chander Mar 29 '22 at 08:08
  • Finally done :) code below `var configuration = UIButton.Configuration.plain() configuration.background.image = UIImage(systemName: "checkmark") configuration.title = "BSC TestNet" configuration.background.imageContentMode = .right testnet.configuration = configuration` – user3614007 Mar 29 '22 at 10:09

0 Answers0