Skip to content

Instantly share code, notes, and snippets.

#import "WeView.h"
UIButton *button = ...;
WeView *panelView = [[WeView alloc] init];
[[[[panelView addSubviewWithCustomLayout:button]
setHAlign:H_ALIGN_CENTER]
setVAlign:V_ALIGN_BOTTOM]
setMargin:20];
UIButton *button = ...;
UIView *superview = ...;
NSDictionary *variableMap = NSDictionaryOfVariableBindings(label, superview);
NSLayoutConstraint *cn = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[button]-12-[superview]"
options:0
metrics:nil
views:variableMap];
[superview addConstraint:cn];
cn = [NSLayoutConstraint constraintsWithVisualFormat:@"H:[superview]-(<=1)-[button]"
options:NSLayoutFormatAlignAllCenterY
UIButton *button = ...;
UIView *superview = ...;
NSLayoutConstraint *cn = [NSLayoutConstraint constraintWithItem:button
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:superview
attribute:NSLayoutAttributeCenterX
multiplier:1.0
constant:0.0];
[superview addConstraint:cn];
WeView *rootView = [[WeView alloc] init];
// Add background image.
UIImage *image = [UIImage imageNamed:@"Images/thun-stockhornkette-1904 1600.jpg"];
UIImageView *background = [[UIImageView alloc] initWithImage:image];
WeView *backgroundWrapper = [[WeView alloc] init];
[[backgroundWrapper addSubviewWithFillLayoutWAspectRatio:background]
setVAlign:V_ALIGN_TOP];
// The background will exceed the backgroundWrapper's bounds, so we need to clip.
backgroundWrapper.clipsToBounds = YES;
WeView *container = [[WeView alloc] init];
[[[container addSubviewsWithHorizontalLayout:@[
label,
imageView,
button,]
setMargin:5]
setSpacing:5];
@charlesmchen
charlesmchen / gist:5534599
Created May 7, 2013 17:47
A fork of Richard Bronosky's simple tool for resigning an iOS app .ipa with a new certificate & provisioning profile.
#!/usr/bin/env bash
# Derived from: https://gist.github.com/RichardBronosky/2878446
realpath(){
echo "$(cd "$(dirname "$1")"; echo -n "$(pwd)/$(basename "$1")")";
}
IPA_SRC="$(realpath $1)"
PROVISIONING_PROFILE="$(realpath $2)"
#define FLURRYLOGERROR(id, msg, err) [FlurryAnalytics logError:id message:msg error:err]
namespace
{
void logUncaughtException(const std::string& type,
const std::string& message)
{
#ifdef DEBUG
NSLog(@"exception error\n%s %s",type.c_str(), message.c_str());
#endif
@charlesmchen
charlesmchen / gist:2846442
Created May 31, 2012 21:32
Possible robofab bug?
'''
My understanding is that TrueType and OpenType external contours should be clockwise;
internal contours should be counter-clockwise.
RGlyph.correctDirection(), however, seems to normalize contours in exactly the opposite manner.
This script reproduces the issue, drawing a simple square.
'''
import os
@charlesmchen
charlesmchen / gist:2656019
Created May 10, 2012 21:28
Robofab Write Otf Sample Logic
import os
import robofab.world
from ufo2fdk import haveFDK
from ufo2fdk import OTFCompiler
font = robofab.world.OpenFont('<path to ufo file>')
@charlesmchen
charlesmchen / gist:2560880
Created April 30, 2012 18:36
Robofab NoneLab test output
dstFolder ./ufo-out
dstFile ./ufo-out/testFamily-Roman.ttf
I found the FDK!
Checking font /font.otf. Start time: Mon Apr 30 15:28:47 2012.
......
Checking 1 -- Warning: Subpath with only 2 graphic elements at 420 206 This may cause problems during 'union' operation. Please inspect. Need to fix wrong orientation on subpath with original moveto at 344 645 Done. Need to fix wrong orientation on subpath with original moveto at 99 451 Done. Need to fix wrong orientation on subpath with original moveto at 631 -32 Done. NOTE: 1 intersection found. Please inspect. (*This may indicate a path with wrong orientation was removed during the 'union' operation, or a path which forms a loop. You can check this by re-running with the '-V' switch on the original data, and look for errors that you don't see when intersections are removed.) Need to fix coincident control points: 142 579 .. 420 206 Please inspect. Need to inspect for possible loop/inflection: 142 579 .. 420 206
..
Checking A -- Warning: Subpath with only 2 gra