附自适应图片的通用代码 适用ios4 ios5 ios6

entation UIImage (CustomUIImage)


- (UIImage *)resizableImageWithCapInsetsCustom:(UIEdgeInsets)capInsets {
    if ([self respondsToSelector:@selector(resizableImageWithCapInsets:resizingMode:)]){
        // iOS 6.x code 
        return  [self resizableImageWithCapInsets:capInsets resizingMode:UIImageResizingModeTile];
        
    }elseif ([self respondsToSelector:@selector(resizableImageWithCapInsets:)]){
        // iOS 5.x code 
        return  [self resizableImageWithCapInsets:capInsets];
        
    }else {
        // iOS 4.x code 
       return [self stretchableImageWithLeftCapWidth:capInsets.top topCapHeight:capInsets.bottom];
    } 
}


@end




注:来自吹乐个球

你可能感兴趣的:(附自适应图片的通用代码 适用ios4 ios5 ios6)