// // ShareCodeView.swift // xingchuangke // // Created by Virgil on 2019/4/21. // Copyright © 2019 Virgil. All rights reserved. // import UIKit class ShareCodeView: UIView { @IBOutlet weak var imgView: UIImageView! @IBOutlet weak var btnSave: UIButton! func initView() { self.setSize(width: ScreenWidth - 40, height: ScreenWidth - 40 + 70) imgView.setSize(width: ScreenWidth - 100, height: ScreenWidth - 100) imgView.marginLeft(left: 30) btnSave.setCenterHorizontallyForSuperView() btnSave.marginTop(top: 20, view: imgView) btnSave.setCornerRadius(size: btnSave.height() / 2) } @IBAction func btnSaveClick(_ sender: Any) { if imgView.image != nil { UIImageWriteToSavedPhotosAlbum(imgView.image!, self, #selector(saveImageResult), nil) } else { SVProgressHUD.showSuccess(withStatus: "保存失败") } } @objc func saveImageResult(image: UIImage, didFinishSavingWithError error: NSError?, contentInfo: AnyObject) { if error != nil { SVProgressHUD.showSuccess(withStatus: "保存失败") } else { SVProgressHUD.showSuccess(withStatus: "保存成功") } } }