Skip to content

Instantly share code, notes, and snippets.

View florieger's full-sized avatar

Florian Rieger florieger

View GitHub Profile
@florieger
florieger / Custom UIBarButtonItem.m
Created August 3, 2011 12:56
Custom UIBarButtonItem
#import <QuartzCore/QuartzCore.h>
- (UIBarButtonItem*)barButtonWithTitle:(NSString*)title target:(id)target action:(SEL)action
{
// Start with a UIButton, because a UIBarButton can't be modified.
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
// Modify layer
[button.layer setCornerRadius:5.0f];
[button.layer setMasksToBounds:YES];
@florieger
florieger / ViewController.m
Created August 5, 2011 12:00
View Controller Lifecycle Management [Xib Version] [MRC]
#pragma mark -
#pragma mark Controller Lifecycle
// Called once the view controller is initialized in your code
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Initialize iVars that live and die with your controller
_myList = [[NSMutableArray alloc] initWithCapacity:5];
@florieger
florieger / .gitignore
Created September 14, 2011 11:40
Default gitignore file for my Xcode projects.
/build/
xcuserdata
*.xcworkspace
.DS_Store
@florieger
florieger / ACSingleton.m
Created October 14, 2011 09:29
Cocoa Singleton implementation [MRC]
#import "ACSingleton.h"
@implementation ACSingleton
#pragma mark -
#pragma mark Singelton Pattern
static ACSingleton.h* _sharedInstance;
// Method to get the shared instance
+ (id)sharedInstance
@florieger
florieger / ViewController.m
Created October 14, 2011 15:56
View Controller Lifecycle Management [Xibless Version] [MRC]
#pragma mark -
#pragma mark Controller Lifecycle
// Called once the view controller is initialized in your code
- (id)init
{
self = [super init];
if (self) {
// Initialize iVars that live and die with your controller
_myList = [[NSMutableArray alloc] initWithCapacity:5];
@florieger
florieger / ACSingleton.m
Created October 21, 2011 11:32
Cocoa Singleton implementation
#import "ACSingleton.h"
@implementation ACSingleton
#pragma mark -
#pragma mark Singleton Pattern
static ACSingleton* _sharedInstance;
static dispatch_once_t _instanceFlag;
@florieger
florieger / ACViewController.h
Last active May 11, 2016 18:43
View Controller Lifecycle Management [Xibless Version]
@interface ACViewController : UIViewController
{
UIViewController* _childViewController;
UIScrollView* _scrollView;
UIButton* _button;
int _counter;
NSString* _text;
CGPoint _lastScrollViewPosition;
}
@florieger
florieger / CustomizeTabBar.m
Created December 2, 2011 11:49
UITabBar Customizing
- (void)customizeTabBar
{
UIImage* tabBarBackground = [UIImage imageNamed:@"tabbar.png"];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
UIImage* selectionIndicator = [UIImage imageNamed:@"selection-tab.png"];
[[UITabBar appearance] setSelectionIndicatorImage:selectionIndicator];
}
#import <QuartzCore/QuartzCore.h>
self.view.layer.masksToBounds = NO;
self.view.layer.shadowColor = [[UIColor blackColor] CGColor];
// Offset to bottom, left
self.view.layer.shadowOffset = CGSizeMake(-1,1);
self.view.layer.shadowRadius = 10;
self.view.layer.shadowOpacity = 1;
@florieger
florieger / ImageLoader.m
Created April 11, 2012 14:22
Memory Efficient Image Loading
#pragma mark -
#pragma mark Memory Efficient Image Loading
+ (UIImage*)imageWithContentsOfFilename:(NSString*)filename
{
NSMutableString* path = [NSMutableString stringWithString:[[NSBundle mainBundle] bundlePath]];
[path appendString:@"/"];
[path appendString:filename];
return [UIImage imageWithContentsOfFile:path];
}