Commit 219de0e9 authored by pete谢兆麟's avatar pete谢兆麟

保存图片逻辑兼容

parent 48bce148
...@@ -26,8 +26,8 @@ class YHHKEventWebViewController: YHBaseViewController { ...@@ -26,8 +26,8 @@ class YHHKEventWebViewController: YHBaseViewController {
// loadData() // loadData()
} }
lazy var bottomViewForSavePic: YHHomeWebViewBottomForSavePicView = { lazy var bottomViewForSavePic: YHWebViewBottomForSavePicView = {
let view = YHHomeWebViewBottomForSavePicView() let view = YHWebViewBottomForSavePicView()
view.isHidden = true view.isHidden = true
return view return view
}() }()
...@@ -47,7 +47,7 @@ extension YHHKEventWebViewController { ...@@ -47,7 +47,7 @@ extension YHHKEventWebViewController {
if model.tag.contains("日历") { if model.tag.contains("日历") {
picUrl = urlString picUrl = urlString
bottomViewForSavePic.isHidden = false // bottomViewForSavePic.isHidden = false
// 创建wkwebview // 创建wkwebview
webview.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height - YHHomeWebViewBottomForSavePicView.viewH - 55 - k_Height_NavigationtBarAndStatuBar) webview.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height - YHHomeWebViewBottomForSavePicView.viewH - 55 - k_Height_NavigationtBarAndStatuBar)
...@@ -62,6 +62,7 @@ extension YHHKEventWebViewController { ...@@ -62,6 +62,7 @@ extension YHHKEventWebViewController {
// 创建wkwebview // 创建wkwebview
webview = WKWebView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height - 0)) webview = WKWebView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height - 0))
webview.navigationDelegate = self
// 添加wkwebview // 添加wkwebview
view.addSubview(webview) view.addSubview(webview)
...@@ -76,6 +77,13 @@ extension YHHKEventWebViewController { ...@@ -76,6 +77,13 @@ extension YHHKEventWebViewController {
} }
} }
extension YHHKEventWebViewController: WKNavigationDelegate {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
if model.tag.contains("日历") {
bottomViewForSavePic.isHidden = false
}
}
}
extension YHHKEventWebViewController { extension YHHKEventWebViewController {
func saveImageToPhotoLib() { func saveImageToPhotoLib() {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import UIKit import UIKit
class YHHomeWebViewBottomForSavePicView: UIView { class YHWebViewBottomForSavePicView: UIView {
static let viewH : CGFloat = 98.0 static let viewH : CGFloat = 98.0
override init(frame: CGRect) { override init(frame: CGRect) {
...@@ -27,7 +27,7 @@ class YHHomeWebViewBottomForSavePicView: UIView { ...@@ -27,7 +27,7 @@ class YHHomeWebViewBottomForSavePicView: UIView {
var saveButton: UIButton! var saveButton: UIButton!
} }
private extension YHHomeWebViewBottomForSavePicView { private extension YHWebViewBottomForSavePicView {
func setupUI() { func setupUI() {
backgroundColor = UIColor(hex: 0x00634A) backgroundColor = UIColor(hex: 0x00634A)
saveButton = { saveButton = {
...@@ -48,3 +48,52 @@ private extension YHHomeWebViewBottomForSavePicView { ...@@ -48,3 +48,52 @@ private extension YHHomeWebViewBottomForSavePicView {
block?(0) block?(0)
} }
} }
class YHHomeWebViewBottomForSavePicView: UIView {
static let viewH : CGFloat = 98.0
override init(frame: CGRect) {
super.init(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: YHBasicInfoFillBottomView.viewH))
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
typealias Block = (Int) -> ()
var block: Block?
var saveButton: UIButton!
}
private extension YHHomeWebViewBottomForSavePicView {
func setupUI() {
backgroundColor = .white
saveButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.contentBkgColor
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.contentHorizontalAlignment = .center
button.setTitle("保存到相册", for: .normal)
button.setTitleColor(UIColor.brandMainColor, for: .normal)
button.layer.cornerRadius = kCornerRadius3
button.layer.borderWidth = 0.5
button.layer.borderColor = UIColor.brandMainColor.cgColor
button.addTarget(self, action: #selector(save), for: .touchUpInside)
return button
}()
addSubview(saveButton)
saveButton.snp.makeConstraints { make in
make.left.equalTo(kMargin)
make.right.equalTo(-kMargin)
make.top.equalTo(12)
make.height.equalTo(44)
}
}
@objc func save() {
block?(0)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment