v0.8.0
This commit is contained in:
@@ -11,5 +11,6 @@
|
||||
@interface UIImage (ShotImage)
|
||||
//截图tableviewi
|
||||
+(UIImage *)saveLongImage:(UITableView *)table;
|
||||
+(UIImage *)saveNavsuitImage:(UITableView *)table;
|
||||
|
||||
@end
|
||||
|
||||
@@ -14,24 +14,39 @@
|
||||
|
||||
UIImage* image = nil;
|
||||
// 下面方法,第一个参数表示区域大小。第二个参数表示是否是非透明的。如果需要显示半透明效果,需要传NO,否则传YES。第三个参数就是屏幕密度了,调整清晰度。
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(table.contentSize, YES, [UIScreen mainScreen].scale);
|
||||
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);
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user