Posts

Showing posts with the label iOS

iOS anti-piracy

NSBundle *bundle = [NSBundle mainBundle]; NSDictionary *info = [bundle infoDictionary]; if ([info objectForKey: @"SignerIdentity"] != nil) { /* do something */ }

Add Font to iOS

http://tetontech.wordpress.com/2010/09/03/using-custom-fonts-in-your-ios-application/ 1) Add the .TTF or .OTF font file/s you wish to use as a resource 2) Open your info.plist and create a new key called UIAppFonts or "Fonts provided by application" , set the key to be an array type. 3) For each font you want to use in your app, add it as a new object in the array with its full name and extension and save the info.plist when finished 4) Now in your code you can simply call [UIFont fontWithName:@"Insert font name here" size:18]

iOS Icons

Universal apps icon requirements. Image Size (px) File Name Used For Required Status 512x512 iTunesArtwork Ad Hoc iTunes Optional but recommended 114x114 Icon@2x.png Home screen for iPhone 4 High Resolution Optional but recommended 72x72 Icon-72.png Home screen for iPad compatibility Optional but recommended 58x58 Icon-Small@2x.png Spotlight and Settings for iPhone 4 High Resolution Recommended if you have a Settings bundle, otherwise optional but recommended 57x57 Icon.png App Store and Home screen on iPhone/iPod touch Required 50x50 Icon-Small-50.png Spotlight for iPad compatibility Recommended if you have a Settings bundle, otherwise optional but recommended 29x29 Icon-Small.png Spotlight and Settings Optional but recommended corner radius for the 512x512 =  80  (iTunesArtwork) corner radius for the 114x114 =  18  (iPhone/iPod touch (Retina)) corner radius for the 72x72 =  11 ...

Adding block callbacks to the Facebook iOS SDK

http://www.icodeblog.com/2011/07/19/adding-block-callbacks-to-the-facebook-ios-sdk/ Under the covers of OAuth http://www.sociallipstick.com/?p=239

UILabel size depending on the amount of text

-( float ) getHeightByWidth :( NSString *) myString :( UIFont *) mySize :( int ) myWidth   {   CGSize boundingSize = CGSizeMake ( myWidth , CGFLOAT_MAX );   CGSize requiredSize = [ myString sizeWithFont : mySize constrainedToSize : boundingSize lineBreakMode : UILineBreakModeWordWrap ];     return requiredSize . height ;   }

UIColor Macros

http://iphonedevelopertips.com/cocoa/uicolor-macros.html  #define RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]  #define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a] // Code without the macro msgLabel.textColor = [ UIColor colorWithRed : 255 / 255.0 green : 251 / 255.0 blue : 204 / 255.0 alpha : 1 ] ;   // Or like this... msgLabel.textColor = [ UIColor colorWithRed : 1.0 green : .98 blue : .8 alpha : 1 ] ;   // Code with macro msgLabel.textColor = RGB ( 255 , 251 , 204 ) ;

Custom UITableViewCell

http://www.bdunagan.com/2009/06/28/custom-uitableviewcell-from-a-xib-in-interface-builder/

Custom UITabBar

Technique 1: http://blog.theanalogguy.be/2010/10/06/custom-colored-uitabbar-icons/ Technique 2: @implementation UITabBar ( CustomImage ) - ( void ) drawRect :( CGRect ) rect {     UIImage * image = [ UIImage imageNamed : @ "background.png" ];     [ image drawInRect : CGRectMake ( 0 , 0 , self . frame . size . width , self . frame . size . height )]; } @end http://stackoverflow.com/questions/675433/custom-colors-in-uitabbar Technique 3 http://idevrecipes.com/2011/01/04/how-does-the-twitter-iphone-app-implement-a-custom-tab-bar/ Technique 4: (Tried and tested) https://github.com/rumex/RXCustomTabBar