Skip to content

Commit

Permalink
fix spacing between UIButton image+text
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Oct 30, 2024
1 parent c0e107d commit 7507a5a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions deltachat-ios/Extensions/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ extension UILabel {
}
}

extension UIButton {
func fixImageAndTitleSpacing() {
let spacing = 6.0
let insetAmount = spacing / 2
let isRTL = UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .rightToLeft
if isRTL {
imageEdgeInsets = UIEdgeInsets(top: 0, left: insetAmount, bottom: 0, right: -insetAmount)
titleEdgeInsets = UIEdgeInsets(top: 0, left: -insetAmount, bottom: 0, right: insetAmount)
contentEdgeInsets = UIEdgeInsets(top: 0, left: -insetAmount, bottom: 0, right: -insetAmount)
} else {
imageEdgeInsets = UIEdgeInsets(top: 0, left: -insetAmount, bottom: 0, right: insetAmount)
titleEdgeInsets = UIEdgeInsets(top: 0, left: insetAmount, bottom: 0, right: -insetAmount)
contentEdgeInsets = UIEdgeInsets(top: 0, left: insetAmount, bottom: 0, right: insetAmount)
}
}
}

extension NSData {
func sha1() -> String {
var digest = [UInt8](repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH))
Expand Down
2 changes: 1 addition & 1 deletion deltachat-ios/View/ChatListEditingBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ChatListEditingBar: UIView {
if showImageAndText {
button.setTitle(imageDescription, for: .normal)
button.setTitleColor(tintColor, for: .normal)
button.imageEdgeInsets = UIEdgeInsets(top: 0, left: -10, bottom: 0, right: 0)
button.fixImageAndTitleSpacing()
}
} else {
button.setTitle(imageDescription, for: .normal)
Expand Down

0 comments on commit 7507a5a

Please sign in to comment.