Breaking News
Home / iOS / iOS Snippets (page 3)

iOS Snippets

How to list all the fonts available in the iOS platform?

A variety of fonts are available in iOS platform. The following code snippet shows how to list all such fonts and add the font names into an array. // array NSMutableArray *fontNames = [[NSMutableArray alloc] init];   // get font family NSArray *fontFamilyNames = [UIFont familyNames];   // loop for …

Read More »

How can you cache CCAnimation in Cocos2D?

Cocos2D provides a simple way to cache you Animations using CCAnimationCache class. The CCAnimationCache is implemented as a singleton which can be accessed using the [CCAnimationCache sharedAnimationCache] method.This approach is particularly useful if the animation steps are common across more than one sprites. [[CCAnimationCache sharedAnimationCache] addAnimation:animationToCache name:@"NameOfAnimation"];     CCAnimation …

Read More »

How to hide UITextView Keyboard in OS?

Basically UITextView is for Multi line Text. However if you want to hid the keyboard when the user presses the Return Key using the following snippet: – (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {      if([text isEqualToString:@"n"])       {                  [textView …

Read More »