Skip to content

Instantly share code, notes, and snippets.

@FahimF
FahimF / Example.m
Created May 29, 2012 13:37
A basic nine-grid sprite node for Cocos2D. You set the contentSize property of the sprite and it will do the layout automatically. The layout also respects the anchorPoint property so it's easy to align the sprites however you want.
CCSprite *sprite = [CCSprite spriteWithFile:@"button9grid.png"];
NGNineGridSprite *nineGrid = [NGNineGridSprite spriteWithSpriteFrame:sprite.displayFrame andCornerSize:CGSizeMake(10, 10)];
nineGrid.position = ccp(160, 240);
nineGrid.anchorPoint = ccp(0.5, 0.5);
nineGrid.contentSize = CGSizeMake(150, 150);
[self addChild:nineGrid];
@FahimF
FahimF / gist:2707734
Created May 16, 2012 05:31 — forked from ironfounderson/gist:661556
UIViewController using blocks
@class BookViewController;
typedef void(^BookViewControllerResponse)(BookViewController *controller);
@interface BookViewController : UIViewController {
BookViewControllerResponse cancelBlock_;
BookViewControllerResponse saveBlock_;
}
@property (nonatomic, copy) BookViewControllerResponse cancelBlock;
@FahimF
FahimF / UIColor+Addition.m
Created May 16, 2012 05:29 — forked from jinthagerman/UIColor+Addition.m
UIColor from hex
// http://stackoverflow.com/questions/1560081/how-can-i-create-a-uicolor-from-a-hex-string
+ (UIColor *) colorWithHex:(int)hex {
return [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16))/255.0
green:((float)((hex & 0xFF00) >> 8))/255.0
blue:((float)(hex & 0xFF))/255.0 alpha:1.0];
}