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
<key>UIAppFonts</key> | |
<array> | |
<string>Nemo Nightmares.ttf</string> | |
</array> |
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 Foundation | |
import UIKit | |
import ImageIO | |
import MobileCoreServices | |
extension UIImage { | |
static func animatedGif(from images: [UIImage]) { | |
let fileProperties: CFDictionary = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: 0]] as CFDictionary | |
let frameProperties: CFDictionary = [kCGImagePropertyGIFDictionary as String: [(kCGImagePropertyGIFDelayTime as String): 1.0]] as CFDictionary | |
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
extension UIImage { | |
func overlayed(with overlay: UIImage) -> UIImage? { | |
defer { | |
UIGraphicsEndImageContext() | |
} | |
UIGraphicsBeginImageContextWithOptions(size, false, scale) | |
self.draw(in: CGRect(origin: .zero, size: size)) | |
overlay.draw(in: CGRect(origin: .zero, size: size)) | |
if let image = UIGraphicsGetImageFromCurrentImageContext() { | |
return image |
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 TOCropViewController | |
extension EditViewController : TOCropViewControllerDelegate { | |
func openCrop(image: UIImage) { | |
let crop = TOCropViewController(image: image) | |
crop.delegate = self | |
present(crop, animated: true, completion: nil) | |
} |
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
extension ViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { | |
func presentImagePicker(allowingEditing: Bool) { | |
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.photoLibrary){ | |
let imagePickerController = UIImagePickerController() | |
imagePickerController.delegate = self | |
imagePickerController.sourceType = UIImagePickerControllerSourceType.photoLibrary; | |
imagePickerController.allowsEditing = allowingEditing | |
self.present(imagePickerController, animated: true, completion: nil) | |
} |
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
extension AVCaptureDevice { | |
var hdrMode: HDRMode { | |
set(newValue){ | |
switch newValue { | |
case .on: | |
automaticallyAdjustsVideoHDREnabled = false | |
isVideoHDREnabled = true | |
case .off: | |
automaticallyAdjustsVideoHDREnabled = false | |
isVideoHDREnabled = false |
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
let motionManager = CMMotionManager() // Class variable, otherwise ARC will delete the object | |
if motionManager.isGyroAvailable { | |
if !motionManager.isGyroActive { | |
motionManager.gyroUpdateInterval = 1.0 / 2.0 | |
motionManager.startGyroUpdates(to: .main, withHandler: { (gyroData, error) in | |
if let gyroData = gyroData { | |
print(String(format: "%.02f %.02f %.02f", gyroData.rotationRate.x, gyroData.rotationRate.y, gyroData.rotationRate.z)) | |
} else if let error = error { | |
print("1Error \(error.localizedDescription)") |
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 SpinView: UIView { | |
private var animating: Bool = false | |
private func spin(with options: UIViewAnimationOptions) { | |
// this spin completes 360 degrees every 2 seconds | |
UIView.animate(withDuration: 0.5, delay: 0, options: options, animations: {() -> Void in | |
self.transform = self.transform.rotated(by: .pi / 2) | |
}, completion: {(_ finished: Bool) -> Void in | |
if finished { | |
if self.animating { |
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
@IBDesignable class GridView: UIView { | |
var numberOfColumns: Int = 2 | |
var numberOfRows: Int = 2 | |
var lineWidth: CGFloat = 1.0 | |
var lineColor: UIColor = UIColor.white | |
override func draw(_ rect: CGRect) { | |
if let context = UIGraphicsGetCurrentContext() { | |
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
// HDR | |
@IBOutlet weak var hdrButton: HDRButton! | |
var currentHDRMode: HDRMode = .auto | |
@IBAction func HDRButtonTouched(_ sender: HDRButton) { | |
toggleHDR() | |
sender.mode = currentHDRMode | |
} |