Instantly share code, notes, and snippets.
hashaam
/ request-camera-authorization-view-iboutlets.swift
Last active
August 16, 2020 16:55
This file contains 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
// Youtube: https://www.youtube.com/watch?v=7AlZxClmhPw | |
// Source: https://hashaam.com/2020/07/30/creating-camera-application-with-avfoundation/ | |
@IBOutlet private weak var cameraImageView: UIImageView! | |
@IBOutlet private weak var titleLabel: UILabel! | |
@IBOutlet private weak var messageLabel: UILabel! | |
@IBOutlet private weak var actionButton: UIButton! |
hashaam
/ request-camera-authorization-action-button-ibaction.swift
Last active
August 16, 2020 16:55
This file contains 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
// 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 { |
hashaam
/ embed-request-camera-authorization-view.swift
Last active
August 16, 2020 16:55
This file contains 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
// Youtube: https://www.youtube.com/watch?v=7AlZxClmhPw | |
// Source: https://hashaam.com/2020/07/30/creating-camera-application-with-avfoundation/ | |
import UIKit | |
class LaunchViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
setupViews() |
hashaam
/ request-camera-authorization-controller.swift
Last active
August 16, 2020 16:54
This file contains 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
// Youtube: https://www.youtube.com/watch?v=7AlZxClmhPw | |
// Source: https://hashaam.com/2020/07/30/creating-camera-application-with-avfoundation/ | |
import Foundation | |
import AVFoundation | |
enum CameraAuthorizationStatus { | |
case notRequested | |
case granted | |
case unauthorized |
hashaam
/ request-camera-authorization.swift
Last active
August 16, 2020 16:54
This file contains 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
// Youtube: https://www.youtube.com/watch?v=7AlZxClmhPw | |
// Source: https://hashaam.com/2020/07/30/creating-camera-application-with-avfoundation/ | |
import AVFoundation | |
AVCaptureDevice.requestAccess(for: .video, completionHandler: { granted in | |
if granted { | |
print("granted") | |
} else { | |
print("unauthorized") |
hashaam
/ get-camera-authorization-status.swift
Last active
August 16, 2020 16:54
This file contains 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
// Youtube: https://www.youtube.com/watch?v=7AlZxClmhPw | |
// Source: https://hashaam.com/2020/07/30/creating-camera-application-with-avfoundation/ | |
import AVFoundation | |
let status = AVCaptureDevice.authorizationStatus(for: .video) | |
switch status { | |
case .authorized: | |
print("authorized") | |
case .notDetermined: |
hashaam
/ request-camera-authorization-method-in-launch-view-controller.swift
Last active
August 16, 2020 16:54
This file contains 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
// Youtube: https://www.youtube.com/watch?v=7AlZxClmhPw | |
// Source: https://hashaam.com/2020/07/30/creating-camera-application-with-avfoundation/ | |
func requestCameraAuthorization() { | |
RequestCameraAuthorizationController.requestCameraAuthorization(completionHandler: { status in | |
switch status { | |
case .granted: | |
print("granted") | |
case .notRequested: | |
break |
hashaam
/ replace-action-button-method.swift
Last active
August 16, 2020 16:53
This file contains 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
// Youtube: https://www.youtube.com/watch?v=7AlZxClmhPw | |
// Source: https://hashaam.com/2020/07/30/creating-camera-application-with-avfoundation/ | |
extension LaunchViewController: RequestCameraAuthorizationViewDelegate { | |
func requestCameraAuthorizationActionButtonTapped() { | |
requestCameraAuthorization() | |
} | |
} |
hashaam
/ launch-view-controller-after-camera-authorization.swift
Last active
August 16, 2020 16:53
This file contains 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
// Youtube: https://www.youtube.com/watch?v=7AlZxClmhPw | |
// Source: https://hashaam.com/2020/07/30/creating-camera-application-with-avfoundation/ | |
import UIKit | |
class LaunchViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
setupViews() |
hashaam
/ request-camera-authorization-add-shadow.swift
Last active
February 5, 2022 20:45
This file contains 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
private extension RequestCameraAuthorizationView { | |
// ... | |
func setupActionButtonShadow() { | |
actionButton.layer.shadowColor = UIColor.black.cgColor | |
actionButton.layer.shadowRadius = 10 | |
actionButton.layer.shadowOpacity = 0.3 | |
actionButton.layer.masksToBounds = false | |
actionButton.layer.shadowOffset = CGSize(width: 5, height: 10) |