美文网首页iOS 开发
cell上的UIImageView点击背景颜色 消失

cell上的UIImageView点击背景颜色 消失

作者: EarthMass | 来源:发表于2016-04-18 16:13 被阅读0次

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

相关文章

网友评论

    本文标题:cell上的UIImageView点击背景颜色 消失

    本文链接:https://www.haomeiwen.com/subject/ycdplttx.html