- (UIImage *)dtk_setImageColor:(UIColor *)imageColor{ //獲取畫布 UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f); //畫筆沾取顏色 [imageColor setFill... ...
- (UIImage *)dtk_setImageColor:(UIColor *)imageColor{ //獲取畫布 UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f); //畫筆沾取顏色 [imageColor setFill]; CGRect bounds = CGRectMake(0, 0, self.size.width, self.size.height); //繪製一次 UIRectFill(bounds); //再繪製一次 [self drawInRect:bounds blendMode:kCGBlendModeOverlay alpha:1.0f]; //獲取圖片 [self drawInRect:bounds blendMode:kCGBlendModeDestinationIn alpha:1.0f]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; }