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
| func formatPriceString(costString:String,costLabel:UILabel) { | |
| if let range = costString.rangeOfString(".") { | |
| let attributeString: NSMutableAttributedString = NSMutableAttributedString(string: costString) | |
| let pos = costString.startIndex.distanceTo(range.startIndex) | |
| let centsRange = NSMakeRange(pos, 3) | |
| let smallFont = UIFont(name: costLabel.font.fontName,size:10) | |
| let offsetAmount = self.costLabel.font.capHeight - smallFont!.capHeight | |
| attributeString.addAttribute(NSFontAttributeName, value: smallFont!, range: centsRange) | |
| attributeString.addAttribute(NSBaselineOffsetAttributeName, value: offsetAmount, range: centsRange) |
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
| // | |
| // IDate.swift | |
| // | |
| // Created by Jonathan Duty on 6/30/16. | |
| // | |
| extension NSDate { | |
| func timeAgoString(numericDates:Bool) -> String { |
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 | |
| func onMain(closure: () -> ()) { | |
| if NSThread.isMainThread() { | |
| closure() | |
| } | |
| else { | |
| dispatch_async(dispatch_get_main_queue(), closure) | |
| } | |
| } |
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 | |
| public extension String { | |
| init(htmlEncodedString: String) { | |
| let encodedData = htmlEncodedString.dataUsingEncoding(NSUTF8StringEncoding)! | |
| let attributedOptions : [String: AnyObject] = [ | |
| NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, | |
| NSCharacterEncodingDocumentAttribute: NSUTF8StringEncoding | |
| ] |
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
| class HumanTime: NSObject { | |
| let minute = 1 | |
| let hour = 60 | |
| let day = 60 * 24 | |
| let week = 60 * 24 * 7 | |
| let now: Date | |
| convenience override init() { | |
| self.init(now: Date()) |
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
| func onMainThread(_ block: @escaping () -> Void) { | |
| DispatchQueue.main.async { | |
| block() | |
| } | |
| } |
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
| struct Device { | |
| let ran: Bool | |
| @discardableResult static func when4sOrSmaller(_ block: () -> Void) -> Device { | |
| return runBlockIfTrue(UIScreen.is4sOrSmaller, block: block) | |
| } | |
| @discardableResult static func when5sOrSmaller(_ block: () -> Void) -> Device { | |
| return runBlockIfTrue(UIScreen.is5sOrSmaller, block: block) | |
| } |
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 class GradientView: UIView { | |
| @IBInspectable var topColor: UIColor = UIColor.white { | |
| didSet { | |
| setNeedsLayout() | |
| } | |
| } | |
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
| class Cell: UITableViewCell { | |
| override func drawRect(rect: CGRect) { | |
| var bubbleSpace = CGRectMake(20.0, self.bounds.origin.y, self.bounds.width - 20, self.bounds.height) | |
| let bubblePath1 = UIBezierPath(roundedRect: bubbleSpace, byRoundingCorners: .TopLeft | .TopRight | .BottomRight, cornerRadii: CGSize(width: 20.0, height: 20.0)) | |
| let bubblePath = UIBezierPath(roundedRect: bubbleSpace, cornerRadius: 20.0) | |
| UIColor.greenColor().setStroke() | |
| UIColor.greenColor().setFill() |
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 | |
| extension UIView { | |
| var absoluteFrame: CGRect { | |
| return self.superview!.convert(self.frame, to: nil) | |
| } | |
| func convertFrame(toParentView parentView: UIView) -> CGRect { | |
| return self.superview!.convert(self.frame, to: parentView) | |
| } |
OlderNewer