/*以原图最短边为边长,居中裁剪 image 为正方形*/
+ (UIImage *)centerClipImage:(UIImage *)image;
/*以原图最短边为边长,居中裁剪 image 为正方形*/
+ (UIImage *)centerClipImage:(UIImage *)image
{if (!image) {return nil;}UIImage *srcImage = image;CGFloat val = 0.f;CGRect rect = CGRectZero;CGSize srcSize = srcImage.size;if ([@(srcSize.width) compare:@(srcSize.height)] == NSOrderedAscending) { // w hval = srcSize.height;rect = CGRectMake((srcSize.width - val) / 2.f, 0.f, val, val);}else { // w = hreturn image;}CGImageRef cg = CGImageCreateWithImageInRect(srcImage.CGImage, rect);UIImage *clippedImage = [UIImage imageWithCGImage:cg];CGImageRelease(cg);return clippedImage;
}