diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 34dd62f..209f673 100755 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -163,7 +163,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0710; - LastUpgradeCheck = 0820; + LastUpgradeCheck = 1030; ORGANIZATIONNAME = Startry; TargetAttributes = { 39D6679C1BE202AC00BF0BD7 = { @@ -174,7 +174,7 @@ }; buildConfigurationList = 39D667981BE202AC00BF0BD7 /* Build configuration list for PBXProject "Example" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -270,14 +270,22 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -317,14 +325,22 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -362,7 +378,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.startry.SwViewCapture.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -378,7 +394,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.startry.SwViewCapture.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Example/Example/ImageViewController.swift b/Example/Example/ImageViewController.swift index 24deff3..2c92d33 100755 --- a/Example/Example/ImageViewController.swift +++ b/Example/Example/ImageViewController.swift @@ -28,7 +28,7 @@ class ImageViewController: UIViewController { self.imageView = UIImageView() self.imageView?.image = image - self.imageView?.contentMode = UIViewContentMode.scaleAspectFit + self.imageView?.contentMode = UIView.ContentMode.scaleAspectFit self.scrollView = UIScrollView() diff --git a/Example/Example/Info.plist b/Example/Example/Info.plist index a1bc787..001b4a1 100755 --- a/Example/Example/Info.plist +++ b/Example/Example/Info.plist @@ -41,6 +41,10 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + LSApplicationCategoryType + + NSPhotoLibraryAddUsageDescription + 是否允许添加照片到相册? UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait diff --git a/Example/Example/STCollectionViewDemoController.swift b/Example/Example/STCollectionViewDemoController.swift index 7d973a4..5fd7068 100644 --- a/Example/Example/STCollectionViewDemoController.swift +++ b/Example/Example/STCollectionViewDemoController.swift @@ -16,10 +16,10 @@ class STCollectionViewDemoController: UIViewController, UICollectionViewDelegate override func viewDidLoad() { super.viewDidLoad() - navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Capture", style: UIBarButtonItemStyle.plain, target: self, action: #selector(STTableViewDemoController.didCaptureBtnClicked(_:))) + navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Capture", style: UIBarButtonItem.Style.plain, target: self, action: #selector(STTableViewDemoController.didCaptureBtnClicked(_:))) let flowLayout = UICollectionViewFlowLayout() - flowLayout.scrollDirection = UICollectionViewScrollDirection.vertical; + flowLayout.scrollDirection = UICollectionView.ScrollDirection.vertical; collectView = UICollectionView(frame: CGRect.zero, collectionViewLayout: flowLayout) collectView?.dataSource = self diff --git a/Example/Example/STDemoAppDelegate.swift b/Example/Example/STDemoAppDelegate.swift index f34c275..8ae22a2 100755 --- a/Example/Example/STDemoAppDelegate.swift +++ b/Example/Example/STDemoAppDelegate.swift @@ -14,7 +14,7 @@ class STDemoAppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + internal func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. self.window = UIWindow(frame: UIScreen.main.bounds) diff --git a/Example/Example/STMenuDemoViewController.swift b/Example/Example/STMenuDemoViewController.swift index 9f8728a..0f226f4 100755 --- a/Example/Example/STMenuDemoViewController.swift +++ b/Example/Example/STMenuDemoViewController.swift @@ -42,19 +42,19 @@ class STMenuDemoViewController: UIViewController { let oldWebViewBtn = UIButton() let collectBtn = UIButton() - viewBtn.setTitleColor(UIColor.black, for: UIControlState.normal) - scrollViewBtn.setTitleColor(UIColor.black, for: UIControlState.normal) - tableViewBtn.setTitleColor(UIColor.black, for: UIControlState.normal) - webViewBtn.setTitleColor(UIColor.black, for: UIControlState.normal) - oldWebViewBtn.setTitleColor(UIColor.black, for: UIControlState.normal) - collectBtn.setTitleColor(UIColor.black, for: UIControlState.normal) + viewBtn.setTitleColor(UIColor.black, for: UIControl.State.normal) + scrollViewBtn.setTitleColor(UIColor.black, for: UIControl.State.normal) + tableViewBtn.setTitleColor(UIColor.black, for: UIControl.State.normal) + webViewBtn.setTitleColor(UIColor.black, for: UIControl.State.normal) + oldWebViewBtn.setTitleColor(UIColor.black, for: UIControl.State.normal) + collectBtn.setTitleColor(UIColor.black, for: UIControl.State.normal) - viewBtn.setTitle("View示例", for: UIControlState.normal) - scrollViewBtn.setTitle("ScrollView示例", for: UIControlState.normal) - tableViewBtn.setTitle("TableView示例", for: UIControlState.normal) - webViewBtn.setTitle("WKWebView示例", for: UIControlState.normal) - oldWebViewBtn.setTitle("UIWebView示例", for: UIControlState.normal) - collectBtn.setTitle("CollectionView示例", for: UIControlState.normal) + viewBtn.setTitle("View示例", for: UIControl.State.normal) + scrollViewBtn.setTitle("ScrollView示例", for: UIControl.State.normal) + tableViewBtn.setTitle("TableView示例", for: UIControl.State.normal) + webViewBtn.setTitle("WKWebView示例", for: UIControl.State.normal) + oldWebViewBtn.setTitle("UIWebView示例", for: UIControl.State.normal) + collectBtn.setTitle("CollectionView示例", for: UIControl.State.normal) view.addSubview(viewBtn) view.addSubview(scrollViewBtn) @@ -65,12 +65,12 @@ class STMenuDemoViewController: UIViewController { let actionSel = #selector(STMenuDemoViewController.didBtnClicked(_:)) - viewBtn.addTarget(self, action: actionSel, for: UIControlEvents.touchUpInside) - scrollViewBtn.addTarget(self, action: actionSel, for: UIControlEvents.touchUpInside) - tableViewBtn.addTarget(self, action: actionSel, for: UIControlEvents.touchUpInside) - webViewBtn.addTarget(self, action: actionSel, for: UIControlEvents.touchUpInside) - oldWebViewBtn.addTarget(self, action: actionSel, for: UIControlEvents.touchUpInside) - collectBtn.addTarget(self, action: actionSel, for: UIControlEvents.touchUpInside) + viewBtn.addTarget(self, action: actionSel, for: UIControl.Event.touchUpInside) + scrollViewBtn.addTarget(self, action: actionSel, for: UIControl.Event.touchUpInside) + tableViewBtn.addTarget(self, action: actionSel, for: UIControl.Event.touchUpInside) + webViewBtn.addTarget(self, action: actionSel, for: UIControl.Event.touchUpInside) + oldWebViewBtn.addTarget(self, action: actionSel, for: UIControl.Event.touchUpInside) + collectBtn.addTarget(self, action: actionSel, for: UIControl.Event.touchUpInside) self.viewBtn = viewBtn self.scrollViewBtn = scrollViewBtn diff --git a/Example/Example/STScrollViewDemoController.swift b/Example/Example/STScrollViewDemoController.swift index 5b77c11..98a24cf 100755 --- a/Example/Example/STScrollViewDemoController.swift +++ b/Example/Example/STScrollViewDemoController.swift @@ -18,7 +18,7 @@ class STScrollViewDemoController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Capture", style: UIBarButtonItemStyle.plain, target: self, action: #selector(STScrollViewDemoController.didCaptureBtnClicked(_:))) + navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Capture", style: UIBarButtonItem.Style.plain, target: self, action: #selector(STScrollViewDemoController.didCaptureBtnClicked(_:))) // Add Some Color View for Capture let orangeView = UIView(frame: CGRect(x: 30, y: 100, width: 100, height: 100)) diff --git a/Example/Example/STTableViewDemoController.swift b/Example/Example/STTableViewDemoController.swift index bbc0340..0ae3f3b 100755 --- a/Example/Example/STTableViewDemoController.swift +++ b/Example/Example/STTableViewDemoController.swift @@ -17,7 +17,7 @@ class STTableViewDemoController: UIViewController, UITableViewDelegate, UITableV override func viewDidLoad() { super.viewDidLoad() - navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Capture", style: UIBarButtonItemStyle.plain, target: self, action: #selector(STTableViewDemoController.didCaptureBtnClicked(_:))) + navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Capture", style: UIBarButtonItem.Style.plain, target: self, action: #selector(STTableViewDemoController.didCaptureBtnClicked(_:))) tableView = UITableView() // tableView diff --git a/Example/Example/STUIWebViewDemoController.swift b/Example/Example/STUIWebViewDemoController.swift index 9c34c30..a8dc339 100755 --- a/Example/Example/STUIWebViewDemoController.swift +++ b/Example/Example/STUIWebViewDemoController.swift @@ -17,7 +17,7 @@ class STUIWebViewDemoController: UIViewController { view.backgroundColor = UIColor.red - navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Capture", style: UIBarButtonItemStyle.plain, target: self, action: #selector(STUIWebViewDemoController.didCaptureBtnClicked(_:))) + navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Capture", style: UIBarButtonItem.Style.plain, target: self, action: #selector(STUIWebViewDemoController.didCaptureBtnClicked(_:))) webView = UIWebView(frame: view.bounds) let url = URL(string: "http://www.startry.com") diff --git a/Example/Example/STViewDemoController.swift b/Example/Example/STViewDemoController.swift index 60d99d1..fab164f 100755 --- a/Example/Example/STViewDemoController.swift +++ b/Example/Example/STViewDemoController.swift @@ -17,7 +17,7 @@ class STViewDemoController: UIViewController { super.viewDidLoad() view.backgroundColor = UIColor.yellow - navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Capture", style: UIBarButtonItemStyle.plain, target: self, action: #selector(STViewDemoController.didCaptureBtnClicked(_:))) + navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Capture", style: UIBarButtonItem.Style.plain, target: self, action: #selector(STViewDemoController.didCaptureBtnClicked(_:))) // Add Some Color View for Capture let orangeView = UIView(frame: CGRect(x: 100, y: 100, width: 20, height: 50)) diff --git a/Example/Example/STWKWebViewDemoController.swift b/Example/Example/STWKWebViewDemoController.swift index b378383..a887e08 100755 --- a/Example/Example/STWKWebViewDemoController.swift +++ b/Example/Example/STWKWebViewDemoController.swift @@ -10,52 +10,51 @@ import UIKit import WebKit class STWKWebViewDemoController: UIViewController { - + var webView: WKWebView? - + override func viewDidLoad() { super.viewDidLoad() - + view.backgroundColor = UIColor.red - - navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Capture", style: UIBarButtonItemStyle.plain, target: self, action: #selector(STWKWebViewDemoController.didCaptureBtnClicked(_:))) - + + navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Capture", style: UIBarButtonItem.Style.plain, target: self, action: #selector(STWKWebViewDemoController.didCaptureBtnClicked(_:))) + webView = WKWebView(frame: self.view.bounds) let url = URL(string: "http://www.startry.com") let request = URLRequest(url: url!) _ = webView?.load(request) - + view.addSubview(webView!) } // override func viewWillAppear(animated: Bool) { // self.navigationController?.setNavigationBarHidden(true, animated: animated) // } - + // override func viewDidAppear(animated: Bool) { // super.viewDidAppear(animated) // self.didCaptureBtnClicked(nil) // } - + override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() // webView?.frame = self.view.bounds } - + // MARK: Events - @objc func didCaptureBtnClicked(_ button: UIButton?){ - - webView?.swContentCapture({ (capturedImage) -> Void in - - UIImageWriteToSavedPhotosAlbum(capturedImage!, self, nil, nil) + @objc func didCaptureBtnClicked(_ button: UIButton?) { - let vc = ImageViewController(image: capturedImage!) + webView?.swContentCapture({ (capturedImage) -> Void in + guard let image = capturedImage else { return } + UIImageWriteToSavedPhotosAlbum(image, self, nil, nil) + let vc = ImageViewController(image: image) self.navigationController?.pushViewController(vc, animated: true) }) - + // webView?.swContentScrollCapture({ (capturedImage) -> Void in // UIImageWriteToSavedPhotosAlbum(capturedImage!, self, nil, nil) -// +// // let vc = ImageViewController(image: capturedImage!) // self.navigationController?.pushViewController(vc, animated: true) // }) diff --git a/SwViewCapture.xcodeproj/project.pbxproj b/SwViewCapture.xcodeproj/project.pbxproj index 052bed8..ba909b1 100755 --- a/SwViewCapture.xcodeproj/project.pbxproj +++ b/SwViewCapture.xcodeproj/project.pbxproj @@ -99,21 +99,22 @@ 39D667801BE2024900BF0BD7 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0800; + LastUpgradeCheck = 1030; ORGANIZATIONNAME = Startry; TargetAttributes = { 39D667881BE2024900BF0BD7 = { CreatedOnToolsVersion = 7.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 1030; }; }; }; buildConfigurationList = 39D667831BE2024900BF0BD7 /* Build configuration list for PBXProject "SwViewCapture" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 39D6677F1BE2024900BF0BD7; productRefGroup = 39D6678A1BE2024900BF0BD7 /* Products */; @@ -153,18 +154,27 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -203,18 +213,27 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -263,7 +282,7 @@ SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -285,7 +304,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/SwViewCapture.xcodeproj/xcshareddata/xcschemes/SwViewCapture.xcscheme b/SwViewCapture.xcodeproj/xcshareddata/xcschemes/SwViewCapture.xcscheme index e056e6f..af2e8fe 100644 --- a/SwViewCapture.xcodeproj/xcshareddata/xcschemes/SwViewCapture.xcscheme +++ b/SwViewCapture.xcodeproj/xcshareddata/xcschemes/SwViewCapture.xcscheme @@ -1,6 +1,6 @@ Void) { + func swContentCapture (_ completionHandler: @escaping (_ capturedImage: UIImage?) -> Void) { self.isCapturing = true @@ -24,7 +24,7 @@ public extension UIScrollView { let bakFrame = self.frame let bakOffset = self.contentOffset let bakSuperView = self.superview - let bakIndex = self.superview?.subviews.index(of: self) + let bakIndex = self.superview?.subviews.firstIndex(of: self) // Scroll To Bottom show all cached view if self.frame.size.height < self.contentSize.height { @@ -86,7 +86,7 @@ public extension UIScrollView { // Simulate People Action, all the `fixed` element will be repeate // SwContentCapture will capture all content without simulate people action, more perfect. - public func swContentScrollCapture (_ completionHandler: @escaping (_ capturedImage: UIImage?) -> Void) { + func swContentScrollCapture (_ completionHandler: @escaping (_ capturedImage: UIImage?) -> Void) { self.isCapturing = true @@ -139,11 +139,11 @@ public extension UIScrollView { public extension UIWebView { - public func swContentCapture (_ completionHandler: @escaping (_ capturedImage: UIImage?) -> Void) { + func swContentCapture (_ completionHandler: @escaping (_ capturedImage: UIImage?) -> Void) { self.scrollView.swContentCapture(completionHandler) } - public func swContentScrollCapture (_ completionHandler: @escaping (_ capturedImage: UIImage?) -> Void) { + func swContentScrollCapture (_ completionHandler: @escaping (_ capturedImage: UIImage?) -> Void) { self.scrollView.swContentScrollCapture(completionHandler) } diff --git a/SwViewCapture/UIView+SwCapture.swift b/SwViewCapture/UIView+SwCapture.swift index c4ca4c3..bffe34c 100755 --- a/SwViewCapture/UIView+SwCapture.swift +++ b/SwViewCapture/UIView+SwCapture.swift @@ -14,7 +14,7 @@ private var SwViewCaptureKey_IsCapturing: String = "SwViewCapture_AssoKey_isCapt public extension UIView { - @objc public func swSetFrame(_ frame: CGRect) { + @objc func swSetFrame(_ frame: CGRect) { // Do nothing, use for swizzling } @@ -39,7 +39,7 @@ public extension UIView { // Ref: chromium source - snapshot_manager, fix wkwebview screenshot bug. // https://chromium.googlesource.com/chromium/src.git/+/46.0.2478.0/ios/chrome/browser/snapshots/snapshot_manager.mm - public func swContainsWKWebView() -> Bool { + func swContainsWKWebView() -> Bool { if self.isKind(of: WKWebView.self) { return true } @@ -51,7 +51,7 @@ public extension UIView { return false } - public func swCapture(_ completionHandler: (_ capturedImage: UIImage?) -> Void) { + func swCapture(_ completionHandler: (_ capturedImage: UIImage?) -> Void) { self.isCapturing = true diff --git a/SwViewCapture/WKWebView+SwCapture.swift b/SwViewCapture/WKWebView+SwCapture.swift index c9bd39f..4d7c214 100755 --- a/SwViewCapture/WKWebView+SwCapture.swift +++ b/SwViewCapture/WKWebView+SwCapture.swift @@ -12,7 +12,7 @@ import ObjectiveC public extension WKWebView { - public func swContentCapture(_ completionHandler:@escaping (_ capturedImage: UIImage?) -> Void) { + func swContentCapture(_ completionHandler:@escaping (_ capturedImage: UIImage?) -> Void) { self.isCapturing = true @@ -49,7 +49,7 @@ public extension WKWebView { let bakFrame = self.frame let bakSuperView = self.superview - let bakIndex = self.superview?.subviews.index(of: self) + let bakIndex = self.superview?.subviews.firstIndex(of: self) // remove WebView from superview & put container view self.removeFromSuperview() @@ -105,7 +105,7 @@ public extension WKWebView { // Simulate People Action, all the `fixed` element will be repeate // SwContentCapture will capture all content without simulate people action, more perfect. - public func swContentScrollCapture (_ completionHandler: @escaping (_ capturedImage: UIImage?) -> Void) { + func swContentScrollCapture (_ completionHandler: @escaping (_ capturedImage: UIImage?) -> Void) { self.isCapturing = true