EGOImageView 无图象

因为在EGOImageView 的setImage:方法中使用了self.frame.size如果初始化EGOImageView没有指定大小或者使用了CGRectZero则会出现此问题

- (void)setImage:(UIImage *)image {
    UIGraphicsBeginImageContext(self.frame.size);
    [self.backgroundImage drawAtPoint:CGPointZero];
    CGRect imageFrame = CGRectMake(self.edgeInsets.left, self.edgeInsets.top,
                                   self.frame.size.width - self.edgeInsets.left - self.edgeInsets.right,
                                   self.frame.size.height - self.edgeInsets.top - self.edgeInsets.bottom
                                   );
    [image drawInRect:imageFrame];
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    [super setImage:img];
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注