Skip to content

Instantly share code, notes, and snippets.

View nickmeehan's full-sized avatar

Nick Meehan nickmeehan

View GitHub Profile
@nickmeehan
nickmeehan / AppDelegate.swift
Created November 3, 2018 19:17
Setting Navigation Bar Colour
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Any other set-up code you need.
// This allows us to access the navigation bar since .appearance returns the proxy for the receiver,
// our UINavigationBar.
let navigationBarAppearace = UINavigationBar.appearance()
// This colour applies to the navigation items and bar button items.
require "fastlane_core"
require "credentials_manager"
module Gym
class Options
def self.available_options
return @options if @options
@options = plain_options
end
@nickmeehan
nickmeehan / av_foundation_begin_session.swift
Created November 7, 2016 20:39
AVFoundation - beginSession
func beginSession() {
do {
let deviceInput = try AVCaptureDeviceInput(device: self.captureDevice)
self.captureSession.addInput(deviceInput)
} catch {
// Handle error and return early.
}
self.previewLayer = AVCaptureVideoPreviewLayer(session: self.captureSession)
if let preview = self.previewLayer {
@nickmeehan
nickmeehan / av_foundation_view_did_load.swift
Created November 7, 2016 19:46
AVFoundation - viewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
let deviceTypes: [AVCaptureDeviceType] = [.builtInDuoCamera, .builtInTelephotoCamera, .builtInWideAngleCamera]
let devices = AVCaptureDeviceDiscoverySession(deviceTypes: deviceTypes, mediaType: AVMediaTypeVideo, position: .back).devices
if let device = devices?.first {
self.captureDevice = device
beginSession()
}
@nickmeehan
nickmeehan / av_foundation_controller_constants_and_variables.swift
Created November 7, 2016 18:58
AVFoundation - Controller Constants and Variables
let captureSession = AVCaptureSession()
var captureDevice: AVCaptureDevice?
var previewLayer: AVCaptureVideoPreviewLayer?
@nickmeehan
nickmeehan / iPadActionSheetPresentationSourceViewAndSourceRectNoPermittedArrows.swift
Created October 11, 2016 20:33
iPad ActionSheet Presentation - SourceView and SourceRect No Permitted Arrows
if let popoverController = alertController.popoverPresentationController {
popoverController.sourceView = self.view
popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
popoverController.permittedArrowDirections = []
}
@nickmeehan
nickmeehan / iPadActionSheetPresentationSourceViewAndSourceRect.swift
Created October 11, 2016 20:29
iPad ActionSheet Presentation - SourceView and SourceRect
if let popoverController = alertController.popoverPresentationController {
popoverController.sourceView = self.view
popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
}
@nickmeehan
nickmeehan / iPadActionSheetPresentationBarButtonItemNoCast.swift
Created October 11, 2016 20:08
iPad ActionSheet Presentation - Bar Button Item No Cast
@IBAction func showDeleteActionSheet(_ sender: UIBarButtonItem) {
let alertController = UIAlertController(title: nil, message: "Alert message.", preferredStyle: .actionSheet)
let defaultAction = UIAlertAction(title: "Default", style: .default, handler: { (alert: UIAlertAction!) -> Void in
// Do some action here.
})
let deleteAction = UIAlertAction(title: "Delete", style: .destructive, handler: { (alert: UIAlertAction!) -> Void in
// Do some destructive action here.
})
@nickmeehan
nickmeehan / iPadActionSheetPresentationBarButtonItemCasting.swift
Last active October 11, 2016 20:02
iPad ActionSheet Presentation - Bar Button Item Casting
@IBAction func showDeleteActionSheet(_ sender: AnyObject) {
let alertController = UIAlertController(title: nil, message: "Alert message.", preferredStyle: .actionSheet)
let defaultAction = UIAlertAction(title: "Default", style: .default, handler: { (alert: UIAlertAction!) -> Void in
// Do some action here.
})
let deleteAction = UIAlertAction(title: "Delete", style: .destructive, handler: { (alert: UIAlertAction!) -> Void in
// Do some destructive action here.
})
@nickmeehan
nickmeehan / iPhoneActionSheetPresentation.swift
Last active October 11, 2016 19:51
iPhone ActionSheet Presentation
@IBAction func showDeleteActionSheet(_ sender: AnyObject) {
let alertController = UIAlertController(title: nil, message: "Alert message.", preferredStyle: .actionSheet)
let defaultAction = UIAlertAction(title: "Default", style: .default, handler: { (alert: UIAlertAction!) -> Void in
// Do some action here.
})
let deleteAction = UIAlertAction(title: "Delete", style: .destructive, handler: { (alert: UIAlertAction!) -> Void in
// Do some destructive action here.
})