1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-10 17:08:39 +00:00

* button font color

This commit is contained in:
ad 2018-04-27 14:05:13 +03:00
parent a0dbfca828
commit cc1332dd02
2 changed files with 18 additions and 10 deletions

View File

@ -95,9 +95,6 @@ class CustomButtonCell: NSButtonCell {
} else {
self.isBordered = false
}
self.font = NSFont.systemFont(ofSize: 15, weight: .regular )
}
required init(coder: NSCoder) {
@ -105,3 +102,18 @@ class CustomButtonCell: NSButtonCell {
}
}
extension NSButton {
var title: String {
get {
return ""
}
set (newTitle) {
let attrTitle = NSMutableAttributedString(string: newTitle as String, attributes: [NSAttributedStringKey.foregroundColor: NSColor.white, NSAttributedStringKey.font: NSFont.systemFont(ofSize: 15, weight: .regular)])
attrTitle.setAlignment(.center, range: NSRange(location: 0, length: newTitle.count))
self.attributedTitle = attrTitle
}
}
}

View File

@ -107,14 +107,10 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
}
self.oldValue = value
button.title = String(format: "%@%.2f", self.prefix, value)
let textRange = NSRange(location: 0, length: button.title.count)
let newTitle = NSMutableAttributedString(string: button.title)
newTitle.addAttribute(NSAttributedStringKey.foregroundColor, value: color, range: textRange)
newTitle.addAttribute(NSAttributedStringKey.font, value: button.font!, range: textRange)
newTitle.setAlignment(.center, range: textRange)
let title = String(format: "%@%.2f", self.prefix, value)
let newTitle = NSMutableAttributedString(string: title as String, attributes: [NSAttributedStringKey.foregroundColor: color, NSAttributedStringKey.font: NSFont.systemFont(ofSize: 15, weight: .regular)])
newTitle.setAlignment(.center, range: NSRange(location: 0, length: title.count))
button.attributedTitle = newTitle
}
}