Skip to content

Instantly share code, notes, and snippets.

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 hashaam/db5185ce71a4742cb4b8b3f91334e3ef to your computer and use it in GitHub Desktop.
Save hashaam/db5185ce71a4742cb4b8b3f91334e3ef to your computer and use it in GitHub Desktop.
// Youtube: https://www.youtube.com/watch?v=7AlZxClmhPw
// Source: https://hashaam.com/2020/07/30/creating-camera-application-with-avfoundation/
import UIKit
protocol RequestCameraAuthorizationViewDelegate: class {
func requestCameraAuthorizationActionButtonTapped()
}
class RequestCameraAuthorizationView: UIView {
@IBOutlet private weak var contentView: UIView!
@IBOutlet private weak var cameraImageView: UIImageView!
@IBOutlet private weak var titleLabel: UILabel!
@IBOutlet private weak var messageLabel: UILabel!
@IBOutlet private weak var actionButton: UIButton!
weak var delegate: RequestCameraAuthorizationViewDelegate?
override init(frame: CGRect) {
super.init(frame: frame)
customInit()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
customInit()
}
private func customInit() {
let bundle = Bundle.main
let nibName = String(describing: Self.self)
bundle.loadNibNamed(nibName, owner: self, options: nil)
addSubview(contentView)
contentView.frame = bounds
contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
}
@IBAction func actionButtonHandler(btn: UIButton) {
delegate?.requestCameraAuthorizationActionButtonTapped()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment