Browse Source

拍摄视图底层级

Chris 5 years ago
parent
commit
5881bc9a3a

+ 11 - 3
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -3783,10 +3783,9 @@
 			isa = PBXGroup;
 			children = (
 				BD929CCD22B904A30098C139 /* PublishViewController.swift */,
-				BD929CD322B906C10098C139 /* PublishVideoRecorderController.swift */,
-				BD1EF11622BA637D0052D87A /* PublishVideoView.swift */,
-				BDFE396C22BB224E0074F203 /* PublishTakePhoto */,
 				BD12B67222B4E99800AEB10B /* PublishMediaPicker */,
+				BDACE21222BB683000109AAD /* PublishTakeVideo */,
+				BDFE396C22BB224E0074F203 /* PublishTakePhoto */,
 				BD13B69F22B9CE8D008BB323 /* PublishEditController */,
 				BD13B6CF22BA03BB008BB323 /* PublishAddTopic */,
 				BD13B6CB22BA03BB008BB323 /* PublishAddAddress */,
@@ -4165,6 +4164,15 @@
 			path = AdressCell;
 			sourceTree = "<group>";
 		};
+		BDACE21222BB683000109AAD /* PublishTakeVideo */ = {
+			isa = PBXGroup;
+			children = (
+				BD929CD322B906C10098C139 /* PublishVideoRecorderController.swift */,
+				BD1EF11622BA637D0052D87A /* PublishVideoView.swift */,
+			);
+			path = PublishTakeVideo;
+			sourceTree = "<group>";
+		};
 		BDAF83AE22B3B6150004BCC3 /* 全部评论的Cell */ = {
 			isa = PBXGroup;
 			children = (

+ 6 - 42
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishVideoRecorderController.swift

@@ -17,57 +17,20 @@ class PublishVideoRecorderController: BaseViewController {
         
         setupViews()
         setupLayouts()
-        
-        
-        
-//        recorder.takePhoto(<#T##handler: ((UIImage?, UIImage?) -> Void)!##((UIImage?, UIImage?) -> Void)!##(UIImage?, UIImage?) -> Void#>)
-//        recorder.startRecording()
-        
-        // 开始预览,cameraPosition 摄像头位置(前置、后置)
-        //        recorder.startPreview(withPositon: AliyunIRecorderCameraPosition.back)
-    }
-    
-    override func viewWillAppear(_ animated: Bool) {
-        navigationBar.isHidden = true
-    }
-    
-    override func viewWillDisappear(_ animated: Bool) {
-        navigationBar.isHidden = false
-        recorder.destroy()
     }
     
     override func setupViews() {
-        view.addSubview(prePriceLabel)
-        view.addSubview(tstView)
+        navigationBar.isHidden = true
         
+        view.addSubview(tstView)
     }
     
     override func setupLayouts() {
-        
-        prePriceLabel.snp.makeConstraints { (make) in
-            make.bottom.equalTo(-40)
-            make.centerX.equalToSuperview()
-            make.size.equalTo(80)
-        }
         tstView.snp.makeConstraints { (make) in
-            make.bottom.equalTo(-80)
-            make.centerX.equalToSuperview()
-            make.width.equalTo(320)
-            make.height.equalTo(100)
+            make.edges.equalToSuperview()
         }
-        
     }
     
-    private lazy var prePriceLabel: UILabel = {
-        let prePriceLabel = UILabel()
-        prePriceLabel.text = "合计"
-        prePriceLabel.textColor = k333333Color
-        prePriceLabel.font = kScaleRegularFont16
-        prePriceLabel.backgroundColor = UIColor.yellow
-        return prePriceLabel
-    }()
-    
-    
     private lazy var recorder: AliyunIRecorder = {
         //清除之前生成的录制路径
         let recordDir: String = AliyunPathManager.createRecrodDir()
@@ -81,7 +44,7 @@ class PublishVideoRecorderController: BaseViewController {
         let recorder = AliyunIRecorder.init(delegate: self as? AliyunIRecorderDelegate, videoSize: CGSize(width: 720, height: 1280))
         
         // 预览视图,必须设置
-        recorder?.preview = self.view;
+        recorder?.preview = tstView.previewView
         
         // 摄像头角度
         recorder?.cameraRotate = 270;
@@ -121,10 +84,11 @@ class PublishVideoRecorderController: BaseViewController {
     
     lazy var tstView: PublishVideoView = {
         let tstView = PublishVideoView()
-        tstView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight-40)
+//        tstView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight)
         return tstView
     }()
     
+    
     //    func recordButtonTouchesBegin {
     //    // 点击录制button开始录制
     //    [self.recorder startRecording];

+ 13 - 19
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishVideoView.swift

@@ -26,26 +26,7 @@ class PublishVideoView: BaseView {
         }
     }
     
-    var tPrice: Int? {
-        didSet {
-            priceLabel.text = priceConversion(price: tPrice ?? 0)
-        }
-    }
     
-    var tNumber: Int? {
-        didSet {
-            accountBtn.setTitle("结算(\(tNumber ?? 0))", for: UIControl.State.normal)
-            if tNumber == 0 {
-                accountBtn.backgroundColor = ke6e6e6Color
-                accountBtn.setTitleColor(k333333Color, for: UIControl.State.normal)
-                accountBtn.isEnabled = false
-            } else {
-                accountBtn.setTitleColor(kffffffColor, for: UIControl.State.normal)
-                accountBtn.backgroundColor = kFFA42FColor
-                accountBtn.isEnabled = true
-            }
-        }
-    }
     
     override func setupViews() {
         self.backgroundColor = kffffffColor
@@ -53,6 +34,9 @@ class PublishVideoView: BaseView {
         addSubview(accountBtn)
         addSubview(priceLabel)
         addSubview(prePriceLabel)
+        addSubview(previewView)
+        
+        insertSubview(previewView, at: 0)
     }
     
     override func setupLayouts() {
@@ -82,6 +66,10 @@ class PublishVideoView: BaseView {
             make.right.equalTo(priceLabel.snp_left).offset(-1)
         }
         
+        previewView.snp.makeConstraints { (make) in
+            make.edges.equalToSuperview()
+        }
+        
     }
     
     private lazy var allSelectBtn: UIButton = {
@@ -131,4 +119,10 @@ class PublishVideoView: BaseView {
         return prePriceLabel
     }()
     
+    // 预览View
+    lazy var previewView: UIView = {
+        let previewView = UIView()
+        return previewView
+    }()
+    
 }