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
protocol LayoutGuideProvider { | |
var leadingAnchor: NSLayoutXAxisAnchor { get } | |
var trailingAnchor: NSLayoutXAxisAnchor { get } | |
var leftAnchor: NSLayoutXAxisAnchor { get } | |
var rightAnchor: NSLayoutXAxisAnchor { get } | |
var topAnchor: NSLayoutYAxisAnchor { get } | |
var bottomAnchor: NSLayoutYAxisAnchor { get } | |
var widthAnchor: NSLayoutDimension { get } | |
var heightAnchor: NSLayoutDimension { get } | |
var centerXAnchor: NSLayoutXAxisAnchor { get } |
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 | |
class CheckBox: UIButton { | |
// Images | |
let checkedImage = UIImage(named: "ic_check_box")! as UIImage | |
let uncheckedImage = UIImage(named: "ic_check_box_outline_blank")! as UIImage | |
// Bool property | |
var isChecked: Bool = false { | |
didSet{ |
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
public extension MKMultiPoint { | |
var coordinates: [CLLocationCoordinate2D] { | |
var coords = [CLLocationCoordinate2D](repeating: kCLLocationCoordinate2DInvalid, | |
count: pointCount) | |
getCoordinates(&coords, range: NSRange(location: 0, length: pointCount)) | |
return coords | |
} | |
} |
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 UIColor { | |
convenience init(hex: String, alpha: CGFloat = 1) { | |
assert(hex[hex.startIndex] == "#", "Expected hex string of format #RRGGBB") | |
let scanner = NSScanner(string: hex) | |
scanner.scanLocation = 1 // skip # | |
var rgb: UInt32 = 0 |
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 "DNLastItemCenteredLayout.h" | |
@implementation DNLastItemCenteredLayout | |
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { | |
NSArray *attributes = [super layoutAttributesForElementsInRect:rect]; | |
for (UICollectionViewLayoutAttributes *attribute in attributes) { | |
NSInteger itemCount = [self.collectionView.dataSource collectionView:self.collectionView | |
numberOfItemsInSection:attribute.indexPath.section]; |
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
//If you have a Bridging-Header: | |
#import <FBSDKCoreKit/FBSDKCoreKit.h> | |
#import <FBSDKLoginKit/FBSDKLoginKit.h> | |
//In your AppDelegate: | |
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [String: AnyObject]?) -> Bool { | |
//App launch code | |
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) | |
//Optionally add to ensure your credentials are valid: |
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
// Create CustomView.xib, set File's Owner to CustomView. | |
// Link the top level view in the XIB to the contentView outlet. | |
class CustomView : UIView { | |
@IBOutlet private var contentView:UIView? | |
// other outlets | |
override init(frame: CGRect) { // for using CustomView in code | |
super.init(frame: frame) | |
self.commonInit() |
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)testThis:(MKPolyline *)stepPolyline | |
{ | |
//route is the MKRoute in this example | |
//but the polyline can be any MKPolyline | |
NSUInteger pointCount = stepPolyline.pointCount; | |
//allocate a C array to hold this many points/coordinates... | |
CLLocationCoordinate2D *routeCoordinates |
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
// | |
// UIImagePickerController+RemoveStatusBar.m | |
// CarpeWorkshop | |
// With thanks to:http://stackoverflow.com/users/2797041/user2797041 | |
// Created by Charles Young on 10/9/13. | |
// Copyright (c) 2013 Charles Young. All rights reserved. | |
// | |
#import "UIImagePickerController+RemoveStatusBar.h" |
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
float padding = 10.0; | |
NSMutableParagraphStyle *editorParagraphStyle = [NSMutableParagraphStyle new]; | |
[editorParagraphStyle setHeadIndent:padding]; | |
[editorParagraphStyle setFirstLineHeadIndent:padding]; | |
[editorParagraphStyle setTailIndent:-padding]; | |
NSDictionary *textAttributes = @{ | |
NSFontAttributeName: [UIFont fontWithName:@"Helvetica" size:14], | |
NSParagraphStyleAttributeName: editorParagraphStyle |
NewerOlder