Reputation: 1445
I created this button here to be an archive button for an inbox.
class ArchiveButton: UIButton {
// MARK: - Initializer
override init(frame: CGRect) {
super.init(frame: frame)
configureButton()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
configureButton()
}
// MARK: - Configuration
private func configureButton() {
self.configuration = createButtonConfiguration()
styleButtonAppearance()
}
// MARK: - Button Configuration
private func createButtonConfiguration() -> UIButton.Configuration {
var configuration = UIButton.Configuration.plain()
// Set the image
configuration.image = UIImage(systemName: "archivebox")
configuration.imagePadding = 12
// Set the title and subtitle
configuration.attributedTitle = TextStyle.header3.attributeString("Chats.Hidden.Inbox.Title.Archive".localized)
configuration.attributedSubtitle = TextStyle.caption1.withColor(.herTextGray).attributeString("Chats.Pagination.Hidden.CTA.Description".localized)
// Content alignment and spacing
configuration.contentInsets = NSDirectionalEdgeInsets(top: 12, leading: 0, bottom: 12, trailing: 0)
configuration.titleAlignment = .leading
return configuration
}
// MARK: - Button Appearance
private func styleButtonAppearance() {
self.layer.cornerRadius = 10
self.layer.borderWidth = 1
self.layer.borderColor = UIColor.herDividerGray.cgColor
self.backgroundColor = .herWhite
self.tintColor = .herBlack
}
}
For english, this looks good:
But for other languages like Japanese, the image icon is shifting over to the left:
I tried messing with this UIButtonConfiguration
some more but there doesn't seem like a lot I can configure. Is there not a way to prevent this shifting icon? I tried the imageReservation value that looked most promising.
But the image reservation value didn't do anything besides add more space to the right of the image and also pushes the text OUT of the UIButton.
Upvotes: 0
Views: 55