평면 색상의 작은 png를 오버레이해야합니다.색상이있는 UIImage 오버레이 : 잘못된 결과
- (UIImage *)overlayWithColor:(UIColor *)overlayColor {
UIGraphicsBeginImageContext(self.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[overlayColor setFill];
CGContextTranslateCTM(context, 0, self.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextSetBlendMode(context, kCGBlendModeNormal);
CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);
CGContextDrawImage(context, rect, self.CGImage);
CGContextClipToMask(context, rect, self.CGImage);
CGContextAddRect(context, rect);
CGContextDrawPath(context,kCGPathFill);
UIImage *coloredImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return coloredImg;
}
하지만 결과는 매우 부드러운 아니지만 ... 여기에 원래 이미지 (검은 색 하나)와 오버레이 이미지 (흰색 하나)
을 : 내가 사용 코드는