Skip to content

Instantly share code, notes, and snippets.

View kishorek's full-sized avatar

Kishore Kumar Uthirapathy kishorek

View GitHub Profile
@kishorek
kishorek / gist:2214415
Created March 27, 2012 09:40 — forked from MugunthKumar/gist:2036521
UIView Shadow within PNG
self.myView.layer.masksToBounds = NO;
self.myView.layer.shadowColor = [UIColor blackColor].CGColor;
self.myView.layer.shadowOffset = CGSizeMake(0.0f, 2.0f);
self.myView.layer.shadowOpacity = 0.7f;
self.myView.layer.shadowRadius = 3.0f;
@kishorek
kishorek / mobile-meta-links.html
Created March 27, 2012 09:41
iOS Web App Configuration
@kishorek
kishorek / gist:2214429
Created March 27, 2012 09:43 — forked from jchatard/gist:375738
UINavigationController background
// #Lighter r,g,b,a #Darker r,g,b,a
#define MAIN_COLOR_COMPONENTS { 0.153, 0.306, 0.553, 1.0, 0.122, 0.247, 0.482, 1.0 }
#define LIGHT_COLOR_COMPONENTS { 0.478, 0.573, 0.725, 1.0, 0.216, 0.357, 0.584, 1.0 }
@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect {
if (imageReady) {
UIImage *img = [UIImage imageNamed: @"navigation_background.png"];
[img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
@kishorek
kishorek / gist:2214434
Created March 27, 2012 09:43 — forked from darkseed/gist:1144990
Custom UINavigation background
@interface UINavigationBar (MyCustomNavBar)
@end
@implementation UINavigationBar (MyCustomNavBar)
- (void) drawRect:(CGRect)rect {
//matching the button color with the bar color
[self setTintColor:[UIColor colorWithRed:0.85f green: 0 blue:0 alpha:1]];
UIImage *barImage = [UIImage imageNamed:@"image.png"];
[barImage drawInRect:rect];
}
@end
@kishorek
kishorek / multi line label.m
Created March 27, 2012 09:45 — forked from darkseed/multi line label.m
How to make a multiline label with dynamic text on the iphone and get the correct height
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 9999)];
myLabel.lineBreakMode = UILineBreakModeWordWrap;
myLabel.numberOfLines = 0;
myLabel.text = @"Some \n dynamic \n multiline \n text";
[myLabel sizeToFit]; // This shrinks the 9999 down to the size of the text
NSLog(@"Actual height is: %f", myLabel.frame.size.height); // Use this for spacing any further elements
[self.view addSubview:title]; // Or add it to a scroll view, or whatever...
[myLabel release];
@kishorek
kishorek / gist:2214440
Created March 27, 2012 09:45 — forked from darkseed/gist:1159376
iPhone check for multitasking
- (BOOL) isMultitaskingCapable
{
UIDevice* device = [UIDevice currentDevice];
BOOL backgroundSupported = NO;
if ([device respondsToSelector:@selector(isMultitaskingSupported)])
backgroundSupported = device.multitaskingSupported;
return backgroundSupported;
}
@kishorek
kishorek / gist:2214441
Created March 27, 2012 09:45 — forked from darkseed/gist:1159375
Check for photos and camera
// Method returns no, when the user doesn't have any photos
[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary];
// Check for camera
- (BOOL) isVideoCameraAvailable
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
NSArray *sourceTypes = [UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];
[picker release];
@kishorek
kishorek / retinacheck.m
Created March 27, 2012 09:45 — forked from darkseed/retinacheck.m
Check for retina display
+ (BOOL) isRetinaDisplay
{
int scale = 1.0;
UIScreen *screen = [UIScreen mainScreen];
if([screen respondsToSelector:@selector(scale)])
scale = screen.scale;
if(scale == 2.0f) return YES;
else return NO;
}
@kishorek
kishorek / checkforgyro.m
Created March 27, 2012 09:45 — forked from darkseed/checkforgyro.m
Check for Gyroscope
- (BOOL) isGyroscopeAvailable
{
#ifdef __IPHONE_4_0
CMMotionManager *motionManager = [[CMMotionManager alloc] init];
BOOL gyroAvailable = motionManager.gyroAvailable;
[motionManager release];
return gyroAvailable;
#else
return NO;
#endif
@kishorek
kishorek / AppDelegate.m
Created March 27, 2012 09:46 — forked from darkseed/AppDelegate.m
UITabBarController+CCAdditions.h
#import "UITabBarController+CCAdditions.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[tabBarController setBackgroundImage:[UIImage imageNamed:@"CustomTabBarBackground.png"]];
[tabBarController.view setNeedsDisplay];
return YES;
}