Created
December 14, 2020 23:36
-
-
Save standinga/ed26261cadc2d69fc58c439b6e863baa to your computer and use it in GitHub Desktop.
ViewController with 3 AVSampleBufferView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AVFoundation | |
import UIKit | |
class ViewController: UIViewController { | |
private let cameraView = AVSampleBufferView() | |
private let encodedView = AVSampleBufferView() | |
private let decodedView = AVSampleBufferView() | |
private let stackView: UIStackView = { | |
let view = UIStackView() | |
view.translatesAutoresizingMaskIntoConstraints = false | |
view.axis = .vertical | |
view.distribution = .fillEqually | |
return view | |
}() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.addSubview(stackView) | |
[cameraView, encodedView, decodedView].forEach { | |
stackView.addArrangedSubview($0) | |
$0.bufferLayer.videoGravity = .resizeAspect | |
} | |
cameraView.layer.backgroundColor = UIColor.red.cgColor | |
encodedView.layer.backgroundColor = UIColor.green.cgColor | |
decodedView.layer.backgroundColor = UIColor.blue.cgColor | |
NSLayoutConstraint.activate([ | |
stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor), | |
stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor), | |
stackView.topAnchor.constraint(equalTo: view.topAnchor), | |
stackView.bottomAnchor.constraint(equalTo: view.bottomAnchor) | |
]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment