Skip to content

Instantly share code, notes, and snippets.

@tpthn
tpthn / iOS General
Created August 10, 2012 20:31
iOS - Detect iOS version
if ( [[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0 )
NSLog (@"iOS version is greater than 5.0");
@tpthn
tpthn / iOS general
Created August 10, 2012 20:33
iOS - dim the screen
//dim the screen base on a slider value
[[UIScreen mainScreen] setBrightness:[(UISlider *)sender value]/100];
@tpthn
tpthn / gist:3516777
Created August 29, 2012 18:33
iOS - dismiss keyboard when touch on background
//--Touch to dismiss keyboard
UIButton *dismissKeyboardButtonBg = [UIButton buttonWithType:UIButtonTypeCustom];
dismissKeyboardButtonBg.backgroundColor = [UIColor clearColor];
[dismissKeyboardButtonBg addTarget:self action:@selector(dismissKeyboard:) forControlEvents:UIControlEventTouchUpInside];
[dismissKeyboardButtonBg setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
[dismissKeyboardButtonBg setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self.view addSubview:dismissKeyboardButtonBg];