Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan King rtking1993

  • London
View GitHub Profile
@rtking1993
rtking1993 / UIAlertController+Extension.swift
Last active Jan 22, 2018
UIAlertController+Extension
View UIAlertController+Extension.swift
// Extension
extension UIAlertController {
convenience init(with error: Error) {
var title: String!
var message: String!
if let error = error as? LocalizedError, let errorDescription = error.errorDescription {
title = errorDescription
@rtking1993
rtking1993 / UIView+Extension.swift
Last active Jan 28, 2018
Implementing UIInterpolatingMotionEffect
View UIView+Extension.swift
import UIKit
// Extension
extension UIView {
func motionEffect(intensity: Int) {
// Set vertical effect
let verticalMotionEffect = UIInterpolatingMotionEffect(keyPath: "center.y", type: .tiltAlongVerticalAxis)
verticalMotionEffect.minimumRelativeValue = -intensity
@rtking1993
rtking1993 / InterpolatingMotionEffect.swift
Created Jan 28, 2018
UIInterpolatingMotionEffect implementation
View InterpolatingMotionEffect.swift
import UIKit
class InterpolatingMotionEffect: UIViewController {
@IBOutlet var exampleView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
View UIViewController+Extension.swift
import UIKit
// Extension
extension UIViewController {
func presentShareSheet(for object: Object) {
guard let text = object.text,
let image = object.image,
let url = object.url else {
return
View ShareSheetViewController.swift
import UIKit
class ShareSheetViewController: UIViewController {
@IBOutlet var exampleLabel: UILabel!
@IBOutlet var exampleImageView: UIImageView!
let exampleURL = URL(string: "https://ios-cookbook.com/")
override func viewDidLoad() {
@rtking1993
rtking1993 / RaceViewController.swift
Last active Jan 31, 2018
Animations with UIViewAnimationOptions
View RaceViewController.swift
import UIKit
// MARK: RaceViewController
class RaceViewController: UIViewController {
// MARK: Outlets
@IBOutlet weak var raceButton: UIButton!
@IBOutlet weak var raceView: UIView!
@rtking1993
rtking1993 / TestViewController.swift
Created Jan 31, 2018
Instantiating a custom UIView
View TestViewController.swift
import UIKit
// MARK: TestViewController
class TestViewController: UIViewController {
// MARK: Outlets
@IBOutlet var testView: TestView!
@rtking1993
rtking1993 / TestView.swift
Last active Jan 31, 2018
Creating a custom UIView
View TestView.swift
import UIKit
// MARK: TestViewDelegate
protocol TestViewDelegate: class {
func testView(_ testView: TestView, didSelect button: UIButton)
}
// MARK: TestView
@rtking1993
rtking1993 / ImagePickerViewController.swift
Last active Feb 4, 2018
Implementing the UIImagePickerViewController
View ImagePickerViewController.swift
import UIKit
// MARK: ImagePickerViewController
class ImagePickerViewController: UIViewController {
// MARK: Outlets
@IBOutlet var cameraButton: UIButton!
@IBOutlet var libraryButton: UIButton!
@rtking1993
rtking1993 / PhotoSliderView.swift
Created Feb 12, 2018
Creating a PhotoSliderView
View PhotoSliderView.swift
import UIKit
// MARK: PhotoSliderView
class PhotoSliderView: UIView {
// MARK: Outlets
@IBOutlet var contentView: UIView!
@IBOutlet var scrollView: UIScrollView!