CG를 사용하여 그려지는 사각형의 너비와 색상을 변경하려고합니다. 다음 함수에서는 이미지를 다른 색상으로 마스킹하지만 너비를 어떻게 변경합니까?이미지 색상을 변경하면서 CGContext의 선폭을 변경 하시겠습니까?
- (void)colorImage:(UIImage *)origImage withColor:(UIColor *)color withWidth:(float) width
{
UIImage *image = origImage;
NSLog(@"%f", width);
CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, width);
CGContextClipToMask(context, rect, image.CGImage);
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImage *flippedImage = [UIImage imageWithCGImage:img.CGImage
scale:1.0 orientation: UIImageOrientationDownMirrored];
self.image = flippedImage;
}