cell点击处于高亮状态UIImageView未设置高亮图片【导致不显示背景颜色】特别是透明的图片
#import"UIImageView+UIImageViewHigLightInCell.h"
@implementationUIImageView (UIImageViewHigLightInCell)
- (void)setImageViewHighLightInCell {
CGRectrect =CGRectMake(0.0f,0.0f,1.0f,1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRefcontext =UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [self.backgroundColorCGColor]);
CGContextFillRect(context, rect);
UIImage*image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
if(self.image) {
image = [selfaddImage:imagetoImage:self.image];
}
self.highlightedImage= image;
}
- (UIImage*)addImage:(UIImage*)bgImage toImage:(UIImage*)frontImage {
UIGraphicsBeginImageContext(frontImage.size);
// Draw image1
[bgImagedrawInRect:CGRectMake(0,0, frontImage.size.width, frontImage.size.height)];
// Draw image2
[frontImagedrawInRect:CGRectMake(0,0, frontImage.size.width, frontImage.size.height)];
UIImage*resultingImage =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
returnresultingImage;
}
@end