Yos*_*far 4 ios swift swift5 xcode11.1
我已将PDF图像作为资产添加到Xcode,我想更改tintColor图像的 ,但没有成功。
我尝试添加User Defined Runtime Attributes,但它不起作用。
也尝试过以编程方式更改,但行不通。
self.buttonBringFriend.imageView.tintColor = UIColor.white
Run Code Online (Sandbox Code Playgroud)
有没有人有办法解决吗?
Xcode 11.1 斯威夫特 5.1
要设置图像颜色,请使用以下方法:
extension UIImageView {
func setImageColor(color: UIColor) {
let templateImage = self.image?.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
self.image = templateImage
self.tintColor = color
}
}
Run Code Online (Sandbox Code Playgroud)
如何使用:-
self.buttonBringFriend.imageView.setImageColor(color: .white)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3085 次 |
| 最近记录: |