cell點擊處于高亮狀態(tài)UIImageView未設(shè)置高亮圖片【導致不顯示背景顏色】特別是透明的圖片
#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