简体   繁体   English

永久着色UIImageView

[英]Tint UIImageView permanently

I'd like to tint a UIImageView, but as of now when I tint it and use the control (for example a button press), the tint disappears. 我想对UIImageView进行着色,但是到目前为止,当我对它进行着色并使用控件(例如按下按钮)时,该着色消失了。 Any thoughts? 有什么想法吗?

class func tintImageView(imageView : UIImageView, withColor color:UIColor) {

    var coloredImage = imageView.image?.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
    imageView.image = coloredImage
    imageView.tintColor = color
}

按钮的controlState可能已更改,并且每个controlState都有自己的imageView。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM