美文网首页
ios UIColor转UIImage

ios UIColor转UIImage

作者: zxb有缘 | 来源:发表于2016-09-07 14:35 被阅读0次

    //UIColor转UIImage

    • (UIImage)createImageWithColor: (UIColor) color
      {
      CGRect rect=CGRectMake(0,0, 1, 1);
      UIGraphicsBeginImageContext(rect.size);
      CGContextRef context = UIGraphicsGetCurrentContext();
      CGContextSetFillColorWithColor(context, [color CGColor]);
      CGContextFillRect(context, rect);
      UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
      return theImage;
      }

    相关文章

      网友评论

          本文标题:ios UIColor转UIImage

          本文链接:https://www.haomeiwen.com/subject/mjmjettx.html