[英]How to change SF Symbols' icon color in UIKit?
In SwiftUI
, you can change the icon's color using foregroundColor
modifier.在
SwiftUI
中,您可以使用foregroundColor
修饰符更改图标的颜色。 So I think there should be a way to change the color in UIKit
.所以我认为应该有一种方法可以改变
UIKit
的颜色。 I looked up the documentation and didn't find anything related to it.我查阅了文档并没有找到任何相关的内容。
Is it possible right now?现在有可能吗?
let iconImage = UIImage(systemName: "chevron.right",
withConfiguration: UIImage.SymbolConfiguration(pointSize: 16, weight: .regular, scale: .medium))
Use:利用:
let icon = UIImageView(image: iconImage.withRenderingMode(.alwaysTemplate))
icon.tintColor = .red
muteCall.setImage(UIImage(systemName: "mic.slash")?.withTintColor(.white, renderingMode: .alwaysOriginal), for: .normal)
Set rendering to always original将渲染设置为始终原始
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.