[英]How to change SF Symbols' icon color in UIKit?
在SwiftUI
中,您可以使用foregroundColor
修飾符更改圖標的顏色。 所以我認為應該有一種方法可以改變UIKit
的顏色。 我查閱了文檔並沒有找到任何相關的內容。
現在有可能嗎?
let iconImage = UIImage(systemName: "chevron.right",
withConfiguration: UIImage.SymbolConfiguration(pointSize: 16, weight: .regular, scale: .medium))
利用:
let icon = UIImageView(image: iconImage.withRenderingMode(.alwaysTemplate))
icon.tintColor = .red
muteCall.setImage(UIImage(systemName: "mic.slash")?.withTintColor(.white, renderingMode: .alwaysOriginal), for: .normal)
將渲染設置為始終原始
let iconImage = UIImage(systemName: "chevron.right",
withConfiguration: UIImage.SymbolConfiguration(pointSize: 16, weight: .regular, scale: .medium))?.withTintColor(.systemGreen)
let image = UIImage(systemName: "arrow.up.circle.fill")?.withTintColor(.black, renderingMode: .alwaysOriginal)
button.setImage(image, for: .normal)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.