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
NSFileManager *fileMgr; | |
NSString *entry; | |
NSString *documentsDir; | |
NSDirectoryEnumerator *enumerator; | |
BOOL isDirectory; | |
// Create file manager | |
fileMgr = [NSFileManager defaultManager]; | |
// Path to documents directory |
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
dispatch_queue_t get_my_background_queue() | |
{ | |
static dispatch_once_t once; | |
static dispatch_queue_t my_queue; | |
dispatch_once(&once, ^{ | |
my_queue = dispatch_queue_create("com.example.background", NULL); | |
}); | |
return my_queue; | |
} |
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 addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWidth, float ovalHeight); | |
{ | |
float fw, fh; | |
if (ovalWidth == 0 || ovalHeight == 0) { | |
CGContextAddRect(context, rect); | |
return; | |
} | |
CGContextSaveGState(context); | |
CGContextTranslateCTM (context, CGRectGetMinX(rect), CGRectGetMinY(rect)); | |
CGContextScaleCTM (context, ovalWidth, ovalHeight); |
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
[[NSGraphicsContext currentContext] saveGraphicsState]; | |
// Change the pattern phase. | |
[[NSGraphicsContext currentContext] setPatternPhase: | |
NSMakePoint(0,[self frame].size.height)]; | |
// Stick the image in a color and fill the view with that color. | |
NSImage *anImage = [NSImage imageNamed:@"bricks"]; | |
[[NSColor colorWithPatternImage:anImage] set]; | |
NSRectFill([self bounds]); |
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
+ (UIImage *) imageWithView:(UIView *)view | |
{ | |
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0); | |
[view.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return img; |
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
NSFileManager *fileMgr; | |
NSString *entry; | |
NSString *documentsDir; | |
NSDirectoryEnumerator *enumerator; | |
BOOL isDirectory; | |
// Create file manager | |
fileMgr = [NSFileManager defaultManager]; | |
// Path to documents directory |
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
// Enumerate the installed font family names | |
[[UIFont familyNames] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) | |
{ | |
debug(@"\nFamily: %@", obj); | |
// Enumerate the font names in the each family | |
[[UIFont fontNamesForFamilyName:obj] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) | |
{ | |
debug(@"\tFont: %@\n", obj); | |
}]; |
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
view.layer.masksToBounds = NO; | |
view.layer.shadowOffset = CGSizeMake(-15, 20); | |
view.layer.shadowRadius = 5; | |
view.layer.shadowOpacity = 0.5; |
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
// Add Swipe Gesture Recognizer | |
- (void)addSwipeBackGesture | |
{ | |
UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)]; | |
[gesture setDirection:UISwipeGestureRecognizerDirectionRight]; | |
[self.view addGestureRecognizer:gesture]; | |
[gesture release]; | |
} | |
// Handle swipe action |
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
// Add Swipe Gesture Recognizer | |
- (void)addSwipeBackGesture | |
{ | |
UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)]; | |
[gesture setDirection:UISwipeGestureRecognizerDirectionRight]; | |
[self.view addGestureRecognizer:gesture]; | |
[gesture release]; | |
} | |
// Handle swipe action |
NewerOlder