GiGaMaskTime/GIGA/Category/UIImage+ShotImage.m

55 lines
2.0 KiB
Objective-C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// UIImage+ShotImage.m
// GIGA
//
// Created by lianxiang on 2018/9/25.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import "UIImage+ShotImage.h"
@implementation UIImage (ShotImage)
+(UIImage *)saveLongImage:(UITableView *)table {
UIImage* image = nil;
// 下面方法第一个参数表示区域大小。第二个参数表示是否是非透明的。如果需要显示半透明效果需要传NO否则传YES。第三个参数就是屏幕密度了调整清晰度。
UIGraphicsBeginImageContextWithOptions(CGSizeMake(table.contentSize.width,table.contentSize.height), YES, [UIScreen mainScreen].scale);
CGPoint savedContentOffset = table.contentOffset;
CGRect savedFrame = table.frame;
table.contentOffset = CGPointZero;
table.frame = CGRectMake(0, 0, table.contentSize.width, table.contentSize.height +100);
[table.layer renderInContext: UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
table.contentOffset = savedContentOffset;
table.frame = savedFrame;
UIGraphicsEndImageContext();
return image;
}
+(UIImage *)saveNavsuitImage:(UITableView *)table {
UIImage* image = nil;
// 下面方法第一个参数表示区域大小。第二个参数表示是否是非透明的。如果需要显示半透明效果需要传NO否则传YES。第三个参数就是屏幕密度了调整清晰度。
UIGraphicsBeginImageContextWithOptions(CGSizeMake(table.contentSize.width,table.contentSize.height+30), YES, [UIScreen mainScreen].scale);
CGPoint savedContentOffset = table.contentOffset;
CGRect savedFrame = table.frame;
table.contentOffset = CGPointZero;
table.frame = CGRectMake(0, 0, table.contentSize.width, table.contentSize.height +30);
[table.layer renderInContext: UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
table.contentOffset = savedContentOffset;
table.frame = savedFrame;
UIGraphicsEndImageContext();
return image;
}
@end