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
#if TARGET_IPHONE_SIMULATOR | |
@interface UIImage (RSSaveToDesktop) | |
/// Creates a RSUIImage directory on desktop and saves image to it. | |
-(void)rs_saveToDesktop; | |
/// Creates a RSUIImage directory on desktop and saves image to it with specified name. | |
-(void)rs_saveToDesktopWithName:(NSString *)customName; |
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 Array | |
{ | |
func crossJoin<E, R>( | |
array: [E], | |
joiner: (t: T, e: E) -> R?) | |
-> [R] | |
{ | |
return arrayCrossJoin(self, array, joiner) | |
} | |
} |
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
func switchRootViewController(rootViewController: UIViewController, animated: Bool, completion: (() -> Void)?) { | |
if animated { | |
UIView.transitionWithView(window, duration: 0.5, options: .TransitionCrossDissolve, animations: { | |
let oldState: Bool = UIView.areAnimationsEnabled() | |
UIView.setAnimationsEnabled(false) | |
self.window!.rootViewController = rootViewController | |
UIView.setAnimationsEnabled(oldState) | |
}, completion: { (finished: Bool) -> () in | |
if completion { | |
completion!() |
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
var mediaJSON = { "categories" : [ { "name" : "Movies", | |
"videos" : [ | |
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org", | |
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ], | |
"subtitle" : "By Blender Foundation", | |
"thumb" : "images/BigBuckBunny.jpg", | |
"title" : "Big Buck Bunny" | |
}, | |
{ "description" : "The first Blender Open Movie from 2006", | |
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ], |
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
// | |
// AFWrapper.swift | |
// AFSwiftDemo | |
// | |
// Created by Ashish on 10/4/16. | |
// Copyright © 2016 Ashish Kakkad. All rights reserved. | |
// | |
import UIKit | |
import Alamofire |
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 | |
class CopyableLabel: UILabel { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
userInteractionEnabled = true | |
addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(CopyableLabel.showMenu(_:)))) | |
} | |
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
public typealias ConstraintsConfiguration = (_ top: NSLayoutConstraint, _ left: NSLayoutConstraint, _ bottom: NSLayoutConstraint, _ right: NSLayoutConstraint) -> Void | |
extension UIView { | |
/** | |
Embeds a subview inside the current view and adds constraints to fit the subview in the whole view. An optional constraints configuration closure can be specified to do extra customization for the added constraints, or you can keep a reference for the added constraints in this closure. | |
- Parameter subview: The subview that will be added | |
- Parameter constraintsConfiguration: The constraint configuration that will be applied to the newly added constraints | |
*/ | |
public func addSubviewWithConstraints(_ subview: UIView, constraintsConfiguration: ConstraintsConfiguration? = nil) { | |
// Required to disable auto generation of constraints |