|
@@ -0,0 +1,90 @@
|
|
|
+//
|
|
|
+// PublishConfirmPhotoController.swift
|
|
|
+// RainbowPlanet
|
|
|
+//
|
|
|
+// Created by Christopher on 2019/6/20.
|
|
|
+// Copyright © 2019 RainbowPlanet. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+import UIKit
|
|
|
+import RxSwift
|
|
|
+import Photos
|
|
|
+
|
|
|
+class PublishConfirmPhotoController: BaseViewController {
|
|
|
+
|
|
|
+ var photoImg: UIImage? {
|
|
|
+ didSet {
|
|
|
+ photoImageView.image = self.photoImg
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override func viewDidLoad() {
|
|
|
+ super.viewDidLoad()
|
|
|
+ setupViews()
|
|
|
+ setupLayouts()
|
|
|
+ }
|
|
|
+
|
|
|
+ override func setupViews() {
|
|
|
+ navigationBar.isHidden = true
|
|
|
+
|
|
|
+ view.addSubview(photoImageView)
|
|
|
+ view.addSubview(retakeBtn)
|
|
|
+ view.addSubview(usePhotoBtn)
|
|
|
+ }
|
|
|
+
|
|
|
+ override func setupLayouts() {
|
|
|
+ photoImageView.snp.makeConstraints { (make) in
|
|
|
+ make.top.left.right.equalToSuperview()
|
|
|
+ make.bottom.equalTo(-kSafeTabBarHeight)
|
|
|
+ }
|
|
|
+ retakeBtn.snp.makeConstraints { (make) in
|
|
|
+ make.left.equalTo(photoImageView.snp_left)
|
|
|
+ make.bottom.equalTo(photoImageView.snp_bottom)
|
|
|
+ make.width.equalTo(125)
|
|
|
+ make.height.equalTo(48)
|
|
|
+ }
|
|
|
+ usePhotoBtn.snp.makeConstraints { (make) in
|
|
|
+ make.right.equalTo(photoImageView.snp_right)
|
|
|
+ make.bottom.equalTo(photoImageView.snp_bottom)
|
|
|
+ make.width.equalTo(125)
|
|
|
+ make.height.equalTo(48)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private lazy var photoImageView: UIImageView = {
|
|
|
+ let photoImageView = UIImageView()
|
|
|
+ return photoImageView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var retakeBtn: UIButton = {
|
|
|
+ let retakeBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ retakeBtn.setTitle("重拍", for: .normal)
|
|
|
+ retakeBtn.setTitleColor(kffffffColor, for: .normal)
|
|
|
+ retakeBtn.titleLabel?.font = kMediumFont15
|
|
|
+ retakeBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ self?.dismiss(animated: true, completion: nil)
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return retakeBtn
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var usePhotoBtn: UIButton = {
|
|
|
+ let usePhotoBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ usePhotoBtn.setTitle("使用照片", for: .normal)
|
|
|
+ usePhotoBtn.setTitleColor(kffffffColor, for: .normal)
|
|
|
+ usePhotoBtn.titleLabel?.font = kMediumFont15
|
|
|
+ usePhotoBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ PHPhotoLibrary.shared().performChanges({
|
|
|
+
|
|
|
+ _ = PHAssetChangeRequest.creationRequestForAsset(from: self!.photoImg!)}, completionHandler: { (success, error) in
|
|
|
+ if success != true{
|
|
|
+ SwiftProgressHUD.shared().showText("保存失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ print("保存成功")
|
|
|
+ })
|
|
|
+
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return usePhotoBtn
|
|
|
+ }()
|
|
|
+
|
|
|
+}
|