This file contains hidden or 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
- (void)layoutSubviews | |
{ | |
[super layoutSubviews]; | |
if (self.numberOfLines == 0 && self.preferredMaxLayoutWidth != CGRectGetWidth(self.frame)) { | |
self.preferredMaxLayoutWidth = self.frame.size.width; | |
[self setNeedsUpdateConstraints]; | |
} | |
} |
This file contains hidden or 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 | |
// Tuple result | |
// Get contents of directory at specified path, returning (filenames, nil) or (nil, error) | |
func contentsOfDirectoryAtPath(path: String) -> (filenames: String[]?, error: NSError?) { | |
var error: NSError? = nil | |
let fileManager = NSFileManager.defaultManager() | |
let contents = fileManager.contentsOfDirectoryAtPath(path, error: &error) |
This file contains hidden or 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
/// Show an OK/Cancel modal box that works in both iOS 7 and iOS 8 | |
func ask(title: String, #message: String, #completion: (answer: Bool) -> Void) { | |
if nil != objc_getClass("UIAlertController".UTF8String) { // use UIAlertController | |
let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert) | |
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: { (action) -> Void in | |
completion(answer: false) | |
}) | |
let okayAction = UIAlertAction(title: "OK", style: .Default, handler: { (action) -> Void in | |
completion(answer: true) | |
}) |
This file contains hidden or 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 AppKit | |
import AVFoundation | |
class MovieWriter: NSObject { | |
func writeImagesAsMovie(_ allImages: [NSImage], videoPath: String, videoSize: CGSize, videoFPS: Int32) { | |
// Create AVAssetWriter to write video | |
guard let assetWriter = createAssetWriter(videoPath, size: videoSize) else { | |
print("Error converting images to video: AVAssetWriter not created") | |
return | |
} |
This file contains hidden or 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
// | |
// BuildTimelapseViewController.swift | |
// | |
// Created by Adam Jensen on 5/9/15. | |
// | |
import JGProgressHUD | |
import JoePro | |
import UIKit |
This file contains hidden or 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
<? | |
/* | |
This is part of the Reprise framework, not yet released publicly. | |
Copyright 2013 Marco Arment. All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright | |
notice, this list of conditions and the following disclaimer. |
This file contains hidden or 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 | |
extension String | |
{ | |
var length: Int { | |
get { | |
return countElements(self) | |
} | |
} | |
This file contains hidden or 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
// | |
// ColorUtil.swift | |
// FantasyMovieLeague | |
// | |
// Created by Ben Dalziel on 2/17/16. | |
// Copyright © 2016 Kinetoplay. All rights reserved. | |
// | |
import SwiftHEXColors |
This file contains hidden or 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
// | |
// FontUtil.swift | |
// FantasyMovieLeague | |
// | |
// Created by Ben Dalziel on 2/17/16. | |
// Copyright © 2016 Kinetoplay. All rights reserved. | |
// | |
import UIKit |
This file contains hidden or 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
override func viewDidLoad() { | |
super.viewDidLoad() | |
let newView = UIView() | |
newView.backgroundColor = UIColor.red | |
newView.translatesAutoresizingMaskIntoConstraints = false | |
view.addSubview(newView) | |
let horizontalConstraint = NSLayoutConstraint(item: newView, attribute: NSLayoutAttribute.centerX, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.centerX, multiplier: 1, constant: 0) | |
let verticalConstraint = NSLayoutConstraint(item: newView, attribute: NSLayoutAttribute.centerY, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.centerY, multiplier: 1, constant: 0) |
OlderNewer