Skip to content

Commit

Permalink
1. 暴露 helper 方法
Browse files Browse the repository at this point in the history
2. 删除无用代码
  • Loading branch information
yulingtianxia committed Jun 28, 2019
1 parent bc3ceeb commit 52c431c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 53 deletions.
1 change: 0 additions & 1 deletion Source/TBActionSheet/UIWindow+TBAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@

- (UIViewController *)tb_viewControllerForStatusBarStyle;
- (UIViewController *)tb_viewControllerForStatusBarHidden;
- (UIImage *)tb_snapshot;
- (UIViewController *)currentViewController;
@end
50 changes: 0 additions & 50 deletions Source/TBActionSheet/UIWindow+TBAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,56 +31,6 @@ - (UIViewController *)tb_viewControllerForStatusBarHidden
return currentViewController;
}

- (UIImage *)tb_snapshot
{
// source (under MIT license): https://github.com/shinydevelopment/SDScreenshotCapture/blob/master/SDScreenshotCapture/SDScreenshotCapture.m#L35

// UIWindow doesn't have to be rotated on iOS 8+.
BOOL ignoreOrientation = kiOS8Later;

UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;

CGSize imageSize = CGSizeZero;
if (UIInterfaceOrientationIsPortrait(orientation) || ignoreOrientation) {
imageSize = [UIScreen mainScreen].bounds.size;
} else {
imageSize = CGSizeMake([UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width);
}

UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextTranslateCTM(context, self.center.x, self.center.y);
CGContextConcatCTM(context, self.transform);
CGContextTranslateCTM(context, -self.bounds.size.width * self.layer.anchorPoint.x, -self.bounds.size.height * self.layer.anchorPoint.y);

// correct for the screen orientation
if (!ignoreOrientation) {
if (orientation == UIInterfaceOrientationLandscapeLeft) {
CGContextRotateCTM(context, (CGFloat)M_PI_2);
CGContextTranslateCTM(context, 0, -imageSize.width);
} else if (orientation == UIInterfaceOrientationLandscapeRight) {
CGContextRotateCTM(context, (CGFloat)-M_PI_2);
CGContextTranslateCTM(context, -imageSize.height, 0);
} else if (orientation == UIInterfaceOrientationPortraitUpsideDown) {
CGContextRotateCTM(context, (CGFloat)M_PI);
CGContextTranslateCTM(context, -imageSize.width, -imageSize.height);
}
}

if([self respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) {
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:NO];
} else {/* iOS 6 */
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
}

CGContextRestoreGState(context);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return image;
}

- (UIViewController *)currentViewController
{
UIViewController *viewController = self.rootViewController;
Expand Down
4 changes: 2 additions & 2 deletions TBActionSheet.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "TBActionSheet"
s.version = "1.7.0"
s.version = "1.7.1"
s.summary = "A Custom&Magical ActionSheet."
s.description = <<-DESC
TBActionSheet is a small library that allows you to substitute Apple's uncustomizable UIActionSheet, with a beautiful and totally customizable actionsheet that you can use in your iOS app. The default style is iOS9/10, you can make your own style. Enjoy!
Expand All @@ -17,7 +17,7 @@ s.platform = :ios, '7.0'
s.requires_arc = true

s.source_files = "Source/**/*.{h,m}"
s.public_header_files = "Source/TBActionSheet/TBActionButton.h", "Source/TBActionSheet/TBActionSheet.h", "Source/TBAlertController/TBAlertController.h"
s.public_header_files = "Source/TBActionSheet/TBActionButton.h", "Source/TBActionSheet/TBActionSheet.h", "Source/TBActionSheet/UIView+TBAdditions.h", "Source/TBActionSheet/UIWindow+TBAdditions.h", "Source/TBAlertController/TBAlertController.h"
s.frameworks = 'Foundation', 'UIKit'

end

0 comments on commit 52c431c

Please sign in to comment.