Skip to content

Instantly share code, notes, and snippets.

@standinga
Created December 14, 2020 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save standinga/ed26261cadc2d69fc58c439b6e863baa to your computer and use it in GitHub Desktop.
Save standinga/ed26261cadc2d69fc58c439b6e863baa to your computer and use it in GitHub Desktop.
ViewController with 3 AVSampleBufferView
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