#pragma mark - 計(jì)算label可以顯示多少個字?jǐn)?shù)
+ (NSInteger)numberOfStringInUpper:(UILabel *)label stringToSeperate:(NSString *)str{? ? CGRect container = label.frame;? ? CGSize detailSize;? ? for (int i = 0; i < [str length]; i ++) {? ? ? ? NSString *textStr = [str substringToIndex:i+1];? ? ? ? NSDictionary *attribute = @{NSFontAttributeName: label.font};? ? ? ? detailSize = [textStr boundingRectWithSize:CGSizeMake(container.size.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading? attributes:attribute context:nil].size;? ? ? ? ? ? ? ? if (detailSize.height > container.size.height) {? ? ? ? ? ? return i;? ? ? ? }? ? }? ? container.size.height = detailSize.height;? ? [label setFrame:container]; //調(diào)整高度? ? return [str length];}
#pragma mark - 計(jì)算文本寬高 -
- (CGSize)getContentStr:(NSString *)text widthSize:(CGFloat)width heightSize:(CGFloat)height FontOfSize:(UIFont *)fontSize
{
CGSize requiredSize;
CGRect rect = [text boundingRectWithSize:CGSizeMake(width, height)
options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesFontLeading
attributes:@{NSFontAttributeName:fontSize}
context:nil];
requiredSize = rect.size;
return requiredSize;
}
#pragma mark - 當(dāng)前視圖大小變化
+ (CAAnimation *)starTimer:(CGFloat)duration original:(CGFloat)original midNumerical:(CGFloat)midNumerical endNumerical:(CGFloat)endNumerical
{
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
animation.values = @[[NSNumber numberWithFloat:original], [NSNumber numberWithFloat:midNumerical], [NSNumber numberWithFloat:endNumerical]];//大小變化倍數(shù)
animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
/*
速度控制函數(shù)(CAMediaTimingFunction)
kCAMediaTimingFunctionLinear(線性):勻速帮毁,給你一個相對靜態(tài)的感覺
kCAMediaTimingFunctionEaseIn(漸進(jìn)):動畫緩慢進(jìn)入实苞,然后加速離開
kCAMediaTimingFunctionEaseOut(漸出):動畫全速進(jìn)入,然后減速的到達(dá)目的地
kCAMediaTimingFunctionEaseInEaseOut(漸進(jìn)漸出):動畫緩慢的進(jìn)入烈疚,中間加速黔牵,然后減速的到達(dá)目的地。 這個是默認(rèn)的動畫行為爷肝。
*/
animation.duration = duration;//動畫執(zhí)行的時間
animation.repeatCount = HUGE_VALF;//播放次數(shù)
animation.autoreverses = NO;// 當(dāng)你設(shè)定這個屬性為 YES 時,在它到達(dá)目的地之后,動畫的返回到開始的值,代替了直接跳轉(zhuǎn)到 開始的值猾浦。
animation.removedOnCompletion = NO;//這個屬性默認(rèn)為 YES,那意味著,在指定的時間段完成后,動畫就自動的從層上移除了陆错。這個一般不用。假如你想要再次用這個動畫時,你需要設(shè)定這個屬性為 NO跃巡。這樣的話,下次你在通過-set 方法設(shè)定動畫的屬 性時,它將再次使用你的動畫,而非默認(rèn)的動畫
animation.fillMode=kCAFillModeForwards;
/*
fillMode的作用就是決定當(dāng)前對象過了非active時間段的行為. 比如動畫開始之前,動畫結(jié)束之后危号。如果是一個動畫CAAnimation,則需要將其removedOnCompletion設(shè)置為NO,要不然fillMode不起作用.
kCAFillModeRemoved 這個是默認(rèn)值,也就是說當(dāng)動畫開始前和動畫結(jié)束后,動畫對layer都沒有影響,動畫結(jié)束后,layer會恢復(fù)到之前的狀態(tài)
kCAFillModeForwards 當(dāng)動畫結(jié)束后,layer會一直保持著動畫最后的狀態(tài)
kCAFillModeBackwards 這個和kCAFillModeForwards是相對的,就是在動畫開始前,你只要將動畫加入了一個layer,layer便立即進(jìn)入動畫的初始狀態(tài)并等待動畫開始.你可以這樣設(shè)定測試代碼,將一個動畫加入一個layer的時候延遲5秒執(zhí)行.然后就會發(fā)現(xiàn)在動畫沒有開始的時候,只要動畫被加入了layer,layer便處于動畫初始狀態(tài)
kCAFillModeBoth 理解了上面兩個,這個就很好理解了,這個其實(shí)就是上面兩個的合成.動畫加入后開始之前,layer便處于動畫初始狀態(tài),動畫結(jié)束后layer保持動畫最后的狀態(tài).
*/
return animation;
}
#pragma mark - 當(dāng)前視圖透明度變化
+ (CAAnimation *)fadeInOutAnimation:(CGFloat)duration fromValue:(CGFloat)fromValue toValue:(CGFloat)toValue
{
//通過keypath創(chuàng)建路徑
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
animation.duration = duration;
animation.repeatCount = HUGE_VALF;
animation.fromValue = [NSNumber numberWithFloat:fromValue];
animation.toValue = [NSNumber numberWithFloat:toValue];
animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
animation.autoreverses = NO;
animation.removedOnCompletion=NO;
animation.fillMode=kCAFillModeForwards;
return animation;
}
#pragma mark - 截取全屏
- (UIImage *)imageFromView:(UIView*)theView
{
UIGraphicsBeginImageContext(theView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[theView.layer renderInContext:context];
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
#pragma mark - 數(shù)組排序
- (NSArray *)getSortingArray:(NSArray *)array{
// 返回一個排好序的數(shù)組钮莲,原來數(shù)組的元素順序不會改變
// 指定元素的比較方法:compare:
NSArray *array2 = [array sortedArrayUsingSelector:@selector(compare:)];
return array2;
}
#pragma mark - 點(diǎn)贊效果 大小變化
- (void)imageViewAnimationLayer:(UIView *)view{
CAKeyframeAnimation *k = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
k.values = @[@(0.1),@(1.0),@(1.2)];
k.keyTimes = @[@(0.0),@(0.5),@(0.8),@(1.0)];
k.calculationMode = kCAAnimationLinear;
[view.layer addAnimation:k forKey:@"trans"];
}
#pragma mark - 獲取當(dāng)前時間
+ (NSString *)getCurrentTime{
//現(xiàn)在時間
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *currentTime = [NSString stringWithFormat:@"%@",[formatter stringFromDate:[NSDate date]]];
formatter = nil;
return currentTime;
}
#pragma mark 圖片壓縮
+ (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize withImage:(UIImage*)selectedImage
{
//方法2
CGFloat scaxy=1.0;
const int maxW = targetSize.width, maxH = targetSize.height;
if (selectedImage.size.height>maxH && selectedImage.size.width >maxW)
{
CGFloat scax = maxH/selectedImage.size.width;
CGFloat scay = maxW/selectedImage.size.height;
if (scax > scay)
{
scaxy = scay;
}
else
{
scaxy = scax;
}
}
UIGraphicsBeginImageContext(CGSizeMake(selectedImage.size.width * scaxy, selectedImage.size.height *scaxy));
// Tell the old image to draw in this new context, with the desired// new size
[selectedImage drawInRect:CGRectMake(0,0,selectedImage.size.width * scaxy, selectedImage.size.height *scaxy)];
UIImage? ? *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
#pragma mark - 隨機(jī)顏色
+(UIColor *)randomColor:(CGFloat)alpha
{
CGFloat red = arc4random_uniform(253);
CGFloat green = arc4random_uniform(254);
CGFloat blue = arc4random_uniform(255);
//? ? CGFloat red = arc4random() % 256 ;//(CGFloat)random()/(CGFloat)RAND_MAX;
//? ? CGFloat green =arc4random() % 256 ; //(CGFloat)random()/(CGFloat)RAND_MAX;
//? ? CGFloat blue = arc4random() % 256 ;//(CGFloat)random()/(CGFloat)RAND_MAX;
return [UIColor colorWithRed:red/255.0f green:green/255.0f blue:blue/255.0f alpha:alpha];
}
// 正則判斷電話號碼地址格式,固話
+(BOOL)isTelePhone:(NSString *)telePhoneNum
{
/**
* 手機(jī)號碼
* 移動:134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188
* 聯(lián)通:130,131,132,152,155,156,185,186
* 電信:133,1349,153,180,189
*/
NSString * MOBILE = @"^1(3[0-9]|5[0-35-9]|8[025-9])\\d{8}$";
/**
10? ? ? ? * 中國移動:China Mobile
11? ? ? ? * 134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188
12? ? ? ? */
NSString * CM = @"^1(34[0-8]|(3[5-9]|5[017-9]|8[278])\\d)\\d{7}$";
/**
15? ? ? ? * 中國聯(lián)通:China Unicom
16? ? ? ? * 130,131,132,152,155,156,185,186
17? ? ? ? */
NSString * CU = @"^1(3[0-2]|5[256]|8[56])\\d{8}$";
/**
20? ? ? ? * 中國電信:China Telecom
21? ? ? ? * 133,1349,153,180,189
22? ? ? ? */
NSString * CT = @"^1((33|53|8[09])[0-9]|349)\\d{7}$";
/**
25? ? ? ? * 大陸地區(qū)固話及小靈通
26? ? ? ? * 區(qū)號:010,020,021,022,023,024,025,027,028,029
27? ? ? ? * 號碼:七位或八位
28? ? ? ? */
//? ? NSString * PHS = @"^0(10|2[0-5789]|\\d{3})\\d{7,8}$";
NSString * PHS = @"^((\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1})|(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1}))$";
//? ? NSString * PHS = @"^(\\b0[1-2]\\d-\\d{8}(-\\d{1,4})?\\b)|(\\b0\\d{3}-\\d{7,8}(-\\d{1,4})?\\b)$";
//? ? NSString * PHS = @"^(0?1[358]\\d{9})|((0(10|2[1-3]|[3-9]\\d{2}))?[1-9]\\d{6,7})$";
NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
NSPredicate *regextestphs = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", PHS];
NSPredicate *regextestcm = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CM];
NSPredicate *regextestcu = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CU];
NSPredicate *regextestct = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CT];
if (([regextestmobile evaluateWithObject:telePhoneNum] == YES)
||([regextestphs evaluateWithObject:telePhoneNum] == YES)
|| ([regextestcm evaluateWithObject:telePhoneNum] == YES)
|| ([regextestct evaluateWithObject:telePhoneNum] == YES)
|| ([regextestcu evaluateWithObject:telePhoneNum] == YES))
{
return YES;
}
else
{
return NO;
}
}
//判斷是否中文
+ (BOOL)isChinese:(NSString *)string{
NSString *miaoNumRegex =@"^[\u4e00-\u9fa5]{0,}$";
NSPredicate *passTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",miaoNumRegex];
return [passTest evaluateWithObject:string];
}
#pragma mark - 計(jì)算文本寬高 -
//+(CGSize)getSize:(NSString *)str widthSize:(CGFloat)width FontOfSize:(CGFloat)fontSize
//{
//? ? CGSize requiredSize;
//? ? if ([str respondsToSelector:@selector(boundingRectWithSize:options:attributes:context:)]) {
//? ? ? ? CGRect rect = [str boundingRectWithSize:(CGSize){width, MAXFLOAT}
//? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? options:NSStringDrawingUsesLineFragmentOrigin
//? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]}
//? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? context:nil];
//? ? ? ? requiredSize = rect.size;
//
//? ? } else {
//
//? ? ? ? requiredSize = [str sizeWithFont:[UIFont systemFontOfSize:fontSize] constrainedToSize:(CGSize){width, MAXFLOAT} lineBreakMode:NSLineBreakByWordWrapping];
//? ? }
//
//? ? return requiredSize;
//}
//+(CGSize)getSize:(NSString *)str widthSize:(CGFloat)width FontOfBSize:(CGFloat)fontSize
//{
//? ? CGSize requiredSize;
//? ? if ([str respondsToSelector:@selector(boundingRectWithSize:options:attributes:context:)]) {
//? ? ? ? CGRect rect = [str boundingRectWithSize:(CGSize){width, MAXFLOAT}
//? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? options:NSStringDrawingUsesLineFragmentOrigin
//? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:fontSize]}
//? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? context:nil];
//? ? ? ? requiredSize = rect.size;
//
//? ? } else {
//
//? ? ? ? requiredSize = [str sizeWithFont:[UIFont boldSystemFontOfSize:fontSize] constrainedToSize:(CGSize){width, MAXFLOAT} lineBreakMode:NSLineBreakByWordWrapping];
//? ? }
//
//? ? return requiredSize;
//}
//身份證號
+ (BOOL)validateIdentityCard: (NSString *)identityCard
{
BOOL flag;
if (identityCard.length <= 0) {
flag = NO;
return flag;
}
NSString *regex2 = @"^(\\d{14}|\\d{17})(\\d|[xX])$";
NSPredicate *identityCardPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex2];
return [identityCardPredicate evaluateWithObject:identityCard];
}
// 判斷郵箱是否正確
+ (BOOL)isValidateEmail:(NSString *)Email
{
NSString *emailCheck = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@",emailCheck];
return [emailTest evaluateWithObject:Email];
}
//判斷字母數(shù)字
+ (BOOL)IsNumber:(NSString *)number
{
//是否字母數(shù)字
NSString *miaoNumRegex =@"^[a-zA-Z0-9_]+$";
NSPredicate *passTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",miaoNumRegex];
return [passTest evaluateWithObject:number];
}
//#pragma mark 圖片壓縮
//+ (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize withImage:(UIImage*)selectedImage
//{
//? ? //方法1
////? ? CGFloat scaxy=1.0;
////? ? CGSize imageSize = selectedImage.size;
////? ? CGFloat targetWidth = targetSize.width;
////? ? CGFloat targetHeight = targetSize.height;
////
////? ? if (CGSizeEqualToSize(imageSize, targetSize) == NO)
////? ? {
////? ? ? ? CGFloat scax = targetWidth / imageSize.width;
////? ? ? ? CGFloat scay =? targetHeight / imageSize.height;
////? ? ? ? if (scax > scay)
////? ? ? ? {
////? ? ? ? ? ? scaxy = scay;
////? ? ? ? }
////? ? ? ? else
////? ? ? ? {
////? ? ? ? ? ? scaxy = scax;
////? ? ? ? }
////? ? }
////
////? ? CGFloat scaledWidth = selectedImage.size.width * scaxy;
////? ? CGFloat scaledHeight = selectedImage.size.height *scaxy;
////
//////? ? UIGraphicsBeginImageContext(CGSizeMake(selectedImage.size.width * scaxy, selectedImage.size.height *scaxy));
////? ? UIGraphicsBeginImageContext(CGSizeMake(scaledWidth, scaledHeight));
////? ? // Tell the old image to draw in this new context, with the desired// new size
//////? ? [selectedImage drawInRect:CGRectMake(0,0,selectedImage.size.width * scaxy, selectedImage.size.height *scaxy)];
////
////? ? CGRect thumbnailRect = CGRectZero;
////? ? thumbnailRect.origin = CGPointMake(0.0, 0.0);
////? ? thumbnailRect.size.width = scaledWidth;
////? ? thumbnailRect.size.height = scaledHeight;
////
////? ? CGContextRef context = UIGraphicsGetCurrentContext();
////? ? CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
////? ? UIRectFill(CGRectMake(0, 0, targetWidth, targetHeight));//clear background
////
////? ? [selectedImage drawInRect:thumbnailRect];
////
////? ? UIImage? ? *newImage = UIGraphicsGetImageFromCurrentImageContext();
////? ? UIGraphicsEndImageContext();
//
//? ? //方法2
//? ? ? ? CGFloat scaxy=1.0;
//? ? ? ? const int maxW = targetSize.width, maxH = targetSize.height;
//? ? ? ? if (selectedImage.size.height>maxH && selectedImage.size.width >maxW)
//? ? ? ? {
//? ? ? ? ? ? CGFloat scax = maxH/selectedImage.size.width;
//? ? ? ? ? ? CGFloat scay = maxW/selectedImage.size.height;
//? ? ? ? ? ? if (scax > scay)
//? ? ? ? ? ? {
//? ? ? ? ? ? ? ? scaxy = scay;
//? ? ? ? ? ? }
//? ? ? ? ? ? else
//? ? ? ? ? ? {
//? ? ? ? ? ? ? ? scaxy = scax;
//? ? ? ? ? ? }
//? ? ? ? }
//? ? ? ? UIGraphicsBeginImageContext(CGSizeMake(selectedImage.size.width * scaxy, selectedImage.size.height *scaxy));
//? ? ? ? // Tell the old image to draw in this new context, with the desired// new size
//? ? ? ? [selectedImage drawInRect:CGRectMake(0,0,selectedImage.size.width * scaxy, selectedImage.size.height *scaxy)];
//? ? ? ? UIImage? ? *newImage = UIGraphicsGetImageFromCurrentImageContext();
//? ? ? ? UIGraphicsEndImageContext();
//
////? 方法3
////? ? //? ? UIImage *selectedImage = self;
////? ? UIImage *newImage = nil;
////? ? CGSize imageSize = selectedImage.size;
////? ? CGFloat width = imageSize.width;
////? ? CGFloat height = imageSize.height;
////? ? CGFloat targetWidth = targetSize.width;
////? ? CGFloat targetHeight = targetSize.height;
////? ? CGFloat scaleFactor = 0.0;
////? ? CGFloat scaledWidth = targetWidth;
////? ? CGFloat scaledHeight = targetHeight;
//////? ? CGPoint thumbnailPoint = CGPointMake(0.0,0.0);
////
////? ? if (CGSizeEqualToSize(imageSize, targetSize) == NO)
////? ? {
////? ? ? ? CGFloat widthFactor = targetWidth / width;
////? ? ? ? CGFloat heightFactor = targetHeight / height;
////
////? ? ? ? if (widthFactor > heightFactor)
////? ? ? ? ? ? scaleFactor = widthFactor; // scale to fit height
////? ? ? ? else
////? ? ? ? ? ? scaleFactor = heightFactor; // scale to fit width
////? ? ? ? scaledWidth? = width * scaleFactor;
////? ? ? ? scaledHeight = height * scaleFactor;
////
////? ? ? ? // center the image 裁剪中間
//////? ? ? ? if (widthFactor > heightFactor)
//////? ? ? ? {
//////? ? ? ? ? ? thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
//////? ? ? ? }
//////? ? ? ? else
//////? ? ? ? ? ? if (widthFactor < heightFactor)
//////? ? ? ? ? ? {
//////? ? ? ? ? ? ? ? thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
//////? ? ? ? ? ? }
////? ? }
////
//////? ? UIGraphicsBeginImageContext(targetSize); // this will crop
////? ? UIGraphicsBeginImageContext(CGSizeMake(scaledWidth, scaledHeight)); // this will crop
////
////? ? CGRect thumbnailRect = CGRectZero;
//////? ? thumbnailRect.origin = thumbnailPoint;
////? ? thumbnailRect.size.width? = scaledWidth;
////? ? thumbnailRect.size.height = scaledHeight;
////
////? ? [selectedImage drawInRect:thumbnailRect];
////
////? ? newImage = UIGraphicsGetImageFromCurrentImageContext();
////? ? if(newImage == nil)
////? ? ? ? NSLog(@"could not scale image");
////
////? ? //pop the context to get back to the default
////? ? UIGraphicsEndImageContext();
//? ? return newImage;
//}
//
//+(UIImage *)scaleAndRotateImage:(UIImage *)image resolution:(int)kMaxResolution{
//? ? CGImageRef imgRef = image.CGImage;
//? ? CGFloat width = CGImageGetWidth(imgRef);
//? ? CGFloat height = CGImageGetHeight(imgRef);
//
//? ? CGAffineTransform transform = CGAffineTransformIdentity;
//? ? CGRect bounds = CGRectMake(0, 0, width, height);
//? ? if (width > kMaxResolution || height > kMaxResolution) {
//? ? ? ? CGFloat ratio = width/height;
//? ? ? ? if (ratio > 1) {
//? ? ? ? ? ? bounds.size.width = kMaxResolution;
//? ? ? ? ? ? bounds.size.height = bounds.size.width / ratio;
//? ? ? ? } else {
//? ? ? ? ? ? bounds.size.height = kMaxResolution;
//? ? ? ? ? ? bounds.size.width = bounds.size.height * ratio;
//? ? ? ? }
//? ? }
//
//? ? CGFloat scaleRatio = bounds.size.width / width;
//? ? CGSize imageSize = CGSizeMake(CGImageGetWidth(imgRef), CGImageGetHeight(imgRef));
//? ? CGFloat boundHeight;
//
//? ? UIImageOrientation orient = image.imageOrientation;
//? ? switch(orient) {
//? ? ? ? case UIImageOrientationUp:
//? ? ? ? ? ? transform = CGAffineTransformIdentity;
//? ? ? ? ? ? break;
//? ? ? ? case UIImageOrientationUpMirrored:
//? ? ? ? ? ? transform = CGAffineTransformMakeTranslation(imageSize.width, 0.0);
//? ? ? ? ? ? transform = CGAffineTransformScale(transform, -1.0, 1.0);
//? ? ? ? ? ? break;
//? ? ? ? case UIImageOrientationDown:
//? ? ? ? ? ? transform = CGAffineTransformMakeTranslation(imageSize.width, imageSize.height);
//? ? ? ? ? ? transform = CGAffineTransformRotate(transform, M_PI);
//? ? ? ? ? ? break;
//? ? ? ? case UIImageOrientationDownMirrored:
//? ? ? ? ? ? transform = CGAffineTransformMakeTranslation(0.0, imageSize.height);
//? ? ? ? ? ? transform = CGAffineTransformScale(transform, 1.0, -1.0);
//? ? ? ? ? ? break;
//? ? ? ? case UIImageOrientationLeftMirrored:
//? ? ? ? ? ? boundHeight = bounds.size.height;
//? ? ? ? ? ? bounds.size.height = bounds.size.width;
//? ? ? ? ? ? bounds.size.width = boundHeight;
//? ? ? ? ? ? transform = CGAffineTransformMakeTranslation(imageSize.height, imageSize.width);
//? ? ? ? ? ? transform = CGAffineTransformScale(transform, -1.0, 1.0);
//? ? ? ? ? ? transform = CGAffineTransformRotate(transform, 3.0 * M_PI / 2.0);
//? ? ? ? ? ? break;
//? ? ? ? case UIImageOrientationLeft:
//? ? ? ? ? ? boundHeight = bounds.size.height;
//? ? ? ? ? ? bounds.size.height = bounds.size.width;
//? ? ? ? ? ? bounds.size.width = boundHeight;
//? ? ? ? ? ? transform = CGAffineTransformMakeTranslation(0.0, imageSize.width);
//? ? ? ? ? ? transform = CGAffineTransformRotate(transform, 3.0 * M_PI / 2.0);
//? ? ? ? ? ? break;
//? ? ? ? case UIImageOrientationRightMirrored:
//? ? ? ? ? ? boundHeight = bounds.size.height;
//? ? ? ? ? ? bounds.size.height = bounds.size.width;
//? ? ? ? ? ? bounds.size.width = boundHeight;
//? ? ? ? ? ? transform = CGAffineTransformMakeScale(-1.0, 1.0);
//? ? ? ? ? ? transform = CGAffineTransformRotate(transform, M_PI / 2.0);
//? ? ? ? ? ? break;
//? ? ? ? case UIImageOrientationRight:
//? ? ? ? ? ? boundHeight = bounds.size.height;
//? ? ? ? ? ? bounds.size.height = bounds.size.width;
//? ? ? ? ? ? bounds.size.width = boundHeight;
//? ? ? ? ? ? transform = CGAffineTransformMakeTranslation(imageSize.height, 0.0);
//? ? ? ? ? ? transform = CGAffineTransformRotate(transform, M_PI / 2.0);
//? ? ? ? ? ? break;
//? ? ? ? default:
//? ? ? ? ? ? [NSException raise:NSInternalInconsistencyException format:@"Invalid image orientation"];
//? ? }
//
//? ? UIGraphicsBeginImageContext(CGSizeMake(floorf(bounds.size.width), floorf(bounds.size.height)));
//? ? CGContextRef context = UIGraphicsGetCurrentContext();
//? ? if (orient == UIImageOrientationRight || orient == UIImageOrientationLeft) {
//? ? ? ? CGContextScaleCTM(context, -scaleRatio, scaleRatio);
//? ? ? ? CGContextTranslateCTM(context, -height, 0);
//? ? } else {
//? ? ? ? CGContextScaleCTM(context, scaleRatio, -scaleRatio);
//? ? ? ? CGContextTranslateCTM(context, 0, -height);
//? ? }
//? ? CGContextConcatCTM(context, transform);
//
//? ? CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, floorf(width), floorf(height)), imgRef);
//? ? UIImage *imageCopy = UIGraphicsGetImageFromCurrentImageContext();
//? ? UIGraphicsEndImageContext();
//? ? return imageCopy;
//}