Instantly share code, notes, and snippets.
-
Sort: Recently created
Sort options
hashaam
/ request-camera-authorization-s2.swift
Created May 7, 2022
Request Camera Authorization - Snippet 2
View request-camera-authorization-s2.swift
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
import UIKit | |
import AVFoundation | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let authorizationStatus = getCameraAuthorization() | |
switch authorizationStatus { |
hashaam
/ request-camera-authorization-s1.swift
Created May 7, 2022
Request Camera Authorization - Snippet 1
View request-camera-authorization-s1.swift
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
import UIKit | |
import AVFoundation // 1: Import AVFoundation | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// 3: Get Camera Authorization and print the result | |
let authorizationStatus = getCameraAuthorization() |
hashaam
/ request-camera-authorization-animation-methods.swift
Created Feb 6, 2022
View request-camera-authorization-animation-methods.swift
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 animateInView(view: UIView, delay: TimeInterval) { | |
view.alpha = 0 | |
view.transform = CGAffineTransform(translationX: 0, y: -20) | |
let animation = UIViewPropertyAnimator(duration: 0.2, curve: .easeInOut) { | |
view.alpha = 1 | |
view.transform = .identity |
hashaam
/ request-camera-authorization-add-shadow-method-call.swift
Created Feb 5, 2022
View request-camera-authorization-add-shadow-method-call.swift
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
class RequestCameraAuthorizationView: UIView { | |
// ... | |
private func customInit() { | |
// ... | |
setupActionButtonShadow() | |
} |
hashaam
/ request-camera-authorization-add-shadow.swift
Last active Feb 5, 2022
View request-camera-authorization-add-shadow.swift
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) |
hashaam
/ launch-view-controller-after-camera-authorization.swift
Last active Aug 16, 2020
View launch-view-controller-after-camera-authorization.swift
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
/ replace-action-button-method.swift
Last active Aug 16, 2020
View replace-action-button-method.swift
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
/ request-camera-authorization-method-in-launch-view-controller.swift
Last active Aug 16, 2020
View request-camera-authorization-method-in-launch-view-controller.swift
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
/ get-camera-authorization-status.swift
Last active Aug 16, 2020
View get-camera-authorization-status.swift
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.swift
Last active Aug 16, 2020
View request-camera-authorization.swift
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") |
NewerOlder