我正在尝试向按钮添加 SF 符号。 我发现我可以改变它的点大小、重量和比例或者它的色调。
但是我不知道如何实现这两种定制。
self.Button = makeToolBarButton(buttonTitle: "plus", buttonFont: NSFont.systemFont(ofSize: buttonSize), image: NSImage(named: "plus.circle.filled")?.withSymbolConfiguration(.init(pointSize: 15, weight: .bold, scale:.large)), { button in
button.params["actionType"] = ButtonType.image
}
这将点大小和颜色结合在一个表达式中:
let button = UIButton()
button.setImage(UIImage(systemName: "plus.circle.filled", withConfiguration: UIImage.SymbolConfiguration(pointSize: 15.0))?.withTintColor(UIColor.red), for: .normal)
另一个例子:
let sc = UIImage.SymbolConfiguration(
pointSize: 17, weight: .light, scale: .medium)
let im = UIImage(systemName: "arrow.left.and.right", withConfiguration: sc)!
btn.setImage(im.withTintColor(.lightGray), for: [])