Skip to content

Instantly share code, notes, and snippets.

View mayoff's full-sized avatar
😷
status messages are fun

Rob Mayoff mayoff

😷
status messages are fun
View GitHub Profile
@mayoff
mayoff / Main.storyboard
Created January 12, 2016 16:41
Map view inside scroll view with screen edge available for paging
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
#if os(iOS)
import UIKit
typealias NSLayoutPriority = UILayoutPriority
#elseif os(OSX)
import AppKit
#endif
public extension NSLayoutAttribute {
/** Return a LayoutAnchor representing attribute `self` of `item`. */
@mayoff
mayoff / appfont-fontello-config.json
Last active November 12, 2018 19:37
Playground for drawing a UILabel with attributed text containing icons from a custom font
{
"name": "appfont",
"css_prefix_text": "icon-",
"css_use_suffix": false,
"hinting": true,
"units_per_em": 1000,
"ascent": 850,
"glyphs": [
{
"uid": "324e9013e79ecf9e0e30a07feffa9d6b",
@mayoff
mayoff / maskCorners.swift
Created November 29, 2015 06:32
Playground for masking corners of a UIView
import XCPlayground
import Foundation
import UIKit
func maskCorners(corners: [UIViewContentMode], ofView view: UIView, toDepth depth: CGFloat) {
let s = 1 + 2 * depth
let path = UIBezierPath()
if corners.contains(.TopLeft) {
path.moveToPoint(CGPoint(x: 0, y: 0 + depth))
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSMutableArray *myNums = [NSMutableArray array];
NSString *inputs = @"392 392 339 394 393 394 339";
for (NSString *word in [inputs componentsSeparatedByString:@" "]) {
NSNumber *n = [NSDecimalNumber decimalNumberWithString:word];
[myNums addObject:n];
- (void)layoutSubviews {
[super layoutSubviews];
void objc_msgSend();
NSLog(@"%@", ((id(*)(id,SEL))objc_msgSend)(self, @selector(recursiveDescription)));
NSLog(@"hcons: %@", [self constraintsAffectingLayoutForAxis:UILayoutConstraintAxisHorizontal]);
NSLog(@"vcons: %@", [self constraintsAffectingLayoutForAxis:UILayoutConstraintAxisVertical]);
}
@mayoff
mayoff / Main.storyboard
Created September 10, 2014 15:04
Storyboard with autolayout constraints for aspect-fit of a subview in a container view, for http://stackoverflow.com/a/25768875/77567
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
@mayoff
mayoff / UIImage+Rob_PDFPage.h
Created August 12, 2013 22:58
A UIImage category that renders one page of a PDF.
#import <UIKit/UIKit.h>
@interface UIImage (Rob_PDFPage)
/**
I return an image in which I have drawn page `pageNumber` of the PDF found at `url`. Pages are numbered starting at 1. If I can't draw the page, I return `nil`.
*/
+ (UIImage *)Rob_imageWithPDFURL:(NSURL *)url pageNumber:(size_t)pageNumber;
@end
@mayoff
mayoff / RobIntrinsicContentSizeHonoringContainerView.h
Created August 10, 2013 19:43
Untested UIView subclass to be used as the custom class of a container view in a storyboard, to make that container view honor the intrinsic content size of its embedded content view.
/**
Use this as the custom class of a container view in a storyboard if you want the container view to honor its embedded view's intrinsic content size.
*/
@interface RobIntrinsicContentSizeHonoringContainerView : UIView
/** Connect this to my width constraint in the storyboard if you want me to use my subview's intrinsic content width. */
@property (nonatomic, strong) IBOutlet NSLayoutConstraint *widthConstraint;
/** Connect this to my height constraint in the storyboard if you want me to use my subview's intrinsic content height. */
@property (nonatomic, strong) IBOutlet NSLayoutConstraint *heightConstraint;