iOS-不间断UIImage
我知道如何给iOS-不间断UIImage,ios,uiimageview,uiimage,tint,Ios,Uiimageview,Uiimage,Tint,我知道如何给ui图像上色: UIImage* originalImage = curiv.image; UIImage* imageForRendering = [originalImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; curiv.image = imageForRendering; curiv.tintColor = [UIColor RedColor]; 但是如何解开原始UIImage?您可以这样尝
ui图像上色
:
UIImage* originalImage = curiv.image;
UIImage* imageForRendering = [originalImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
curiv.image = imageForRendering;
curiv.tintColor = [UIColor RedColor];
但是如何解开原始
UIImage
?您可以这样尝试
UIImage* originalImage = curiv.image;
UIImage* imageForRendering = [originalImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
curiv.image = imageForRendering;
UIColor *prevTintColor = curiv.tintColor;
//set new Tint color as Red
curiv.tintColor = [UIColor redColor];
//Now if you want to set back previous color
curiv.tintColor=prevTintColor;
享受编码 您可以保存
UIImage
的tintcolor
,就在用红色着色之前,现在您要解开它,然后设置以前保存的tintcolor。如果不是这样,请提供更多代码以了解详细信息。@ViralSavaj如何保存UIImage
的tintColor
?这是关于我的tintColor
的代码。请看我的答案,因为UIImageView
的默认tintColor
是nil
您可以再次将其设置为nil
以恢复到其原始状态…它可以工作,但不能真正解决我的问题。因为ui图像
都是动态的,我可能有几个要解开。无论如何,感谢您的解决方案。WKInterfaceImage或UIImage对象中没有tintColor属性。developer.apple.com上的开发者文档不公开任何名为“tintColor”的方法,但如果我错了,请随时纠正我。@simonzhu你说得对了一半,没有“UIImage”的tintColor
,但我们已经为UIImageView
获取并设置了tintColor
,在上面的问答中,curiv是UIImageView的对象。因此,我们可以为此设置tintColor
。您可以从Apple Developer文档中查阅此信息。