大佬教程收集整理的这篇文章主要介绍了ios – CGContextSetFillColorWithColor:无效上下文0x0,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我从这个方法的[color setFill]行得到错误.有什么想法可以解决吗?
+ (UIImage *)fillImage:(UIImage*)image withColor:(UIColor *)color { // begin a new image context,to draw our colored image onto UIGraphicsBeginImageContextWithOptions(image.size,NO,[[UIScreen mainScreen] scale]); // get a reference to that context we created CGContextRef context = UIGraphicsGetCurrentContext(); // set the fill color [color setFill]; // translate/flip the graphics context (for transforming from CG* coords to UI* coords CGContextTranslateCTM(context,image.size.height); CGContextScaleCTM(context,1.0,-1.0); // set the blend mode to overlay,and the original image CGContextSetBlendMode(context,kCGBlendModeOverlay); CGRect rect = CGRectMake(0,image.size.width,image.size.height); //if(overlay) CGContextDrawImage(context,rect,img.CGImagE); // set a mask that matches the shape of the image,then draw (overlay) a colored rectangle CGContextClipToMask(context,image.CGImagE); CGContextAddRect(context,rect); CGContextDrawPath(context,kCGPathFill); // generate a new UIImage from the graphics context we drew onto UIImage *coloredImg = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); //return the color-burned image return coloredImg; }
图像本身可能是零.当您将大小消息发送到nil时,您将返回CGSizeZero.
以上是大佬教程为你收集整理的ios – CGContextSetFillColorWithColor:无效上下文0x0全部内容,希望文章能够帮你解决ios – CGContextSetFillColorWithColor:无效上下文0x0所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。