Changing UIImage color

前端 未结 13 1485
我寻月下人不归
我寻月下人不归 2020-11-28 19:28

I\'m trying to change color of UIImage. My code:

-(UIImage *)coloredImage:(UIImage *)firstImage withColor:(UIColor *)color {
    UIGraphicsBeginImageContext(         


        
13条回答
  •  一向
    一向 (楼主)
    2020-11-28 19:54

    In Swift 3.0

    imageView.image? = (imageView.image?.withRenderingMode(.alwaysTemplate))!
    imageView.tintColor = UIColor.magenta
    

    In Swift 2.0

    yourImage.image? = (yourImage.image?.imageWithRenderingMode(.AlwaysTemplate))!
    yourImage.tintColor = UIColor.magentaColor()
    

    Enjoy you Swift pioneers

提交回复
热议问题