[iOS]ボタンテキストの左揃え、画像とテキストの間隔
extension UIButton {
func alignTextLeft(spacing: CGFloat = 8.0) {
contentHorizontalAlignment = .leading
titleEdgeInsets = UIEdgeInsets(top: 0, left: spacing/2, bottom: 0, right: -spacing/2)
imageEdgeInsets = UIEdgeInsets(top: 0, left: -spacing/2, bottom: 0, right: spacing/2)
contentEdgeInsets = UIEdgeInsets(top: 0, left: spacing / 2, bottom: 0, right: -spacing / 2)
}
}
Reference
この問題について([iOS]ボタンテキストの左揃え、画像とテキストの間隔), 我々は、より多くの情報をここで見つけました https://velog.io/@ezidayzi/iOS-Button-Text-왼쪽-정렬-image-와-text-간에-spacing-주기テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol