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 { | |
| func truncateEnd(length: Int, omissionMarker: String? = "...") -> String { | |
| guard self.characters.count > length else { return self } | |
| return self.substringToIndex(self.startIndex.advancedBy(length)) + (omissionMarker ?? "") | |
| } |
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
| extension UIImage { | |
| /** | |
| Returns a new `UIImage` with an adjusted exposure value. | |
| - Parameter ev: The amount to adjust the exposure value. Negative for darker, positive for lighter. | |
| - Returns: a new `UIImage` with an adjusted exposure value. | |
| */ | |
| func imageWithAdjustedExposure(ev: Double) -> UIImage? { | |
| guard let cgImage = self.CGImage else { return nil } |
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 UIKit | |
| public extension UIColor { | |
| public static func checkerboardColor(size: CGSize? = CGSize(width: 100, height: 100), color1: UIColor? = UIColor.grayColor(), color2: UIColor? = UIColor.darkGrayColor()) -> UIColor? { | |
| guard let checkers = CIFilter(name: "CICheckerboardGenerator") else { return nil } | |
| let color0 = CoreImage.CIColor(color: color1!) | |
| let color1 = CoreImage.CIColor(color: color2!) | |
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 UIKit | |
| @IBDesignable public class GradientView: UIView { | |
| // MARK: - Internal | |
| @IBInspectable public var color1: UIColor = UIColor.magentaColor() | |
| @IBInspectable public var color2: UIColor = UIColor.cyanColor() | |
| @IBInspectable public var color3: UIColor = UIColor.clearColor() | |
| @IBInspectable public var color4: UIColor = UIColor.clearColor() |
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
| //: An `AVFoundation` Playground for playing video with `AVPlayer`. Using just a bare `AVPlayer`, there will be no playback controls. | |
| import UIKit | |
| import PlaygroundSupport | |
| import AVFoundation | |
| class MyViewController : UIViewController { | |
| // Other example streams can be found here: https://developer.apple.com/streaming/examples/ | |
| let url = URL(string: "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8")! |
OlderNewer