Thursday, 19 January 2017

Getting Current Location

The Core Location Framework provide the Objective-C interface for obtaining information about current location and heading(direction in which device is pointing) of user. By using this framework we can configure and schedule delivery of location and heading event and can define geographic regions.

Get current location:
CLLocationManager class have ability to deliver current location and heading event. We can use this class for start and stop delivery of  location and heading event. Its provide all event information through delegates methods(CLLocationManagerDelegate).

Here code snippet for getting current location

-(void) getCurrentLocation{
    //Create an instance of CLLocationManager
    CLLocationManager * locationManager = [[CLLocationManager alloc] init];

    // Set delegate
    locationManager.delegate = self;

   // set accuracy
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;

    //request for authorization
    if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
        [locationManager requestWhenInUseAuthorization];
    }

    //start updating locations
    [locationManager startUpdatingLocation];
}


Now define the delegate method for getting location inforamation

-(void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
    CLLocation *currentLocation = [locations lastObject];
    NSLog(@"Location latitude - %f",currentLocation.coordinate.latitude);
    NSLog(@"Location longitude - %f", currentLocation.coordinate.latitude);
}

// get error message to fetch location
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
    NSLog(@"didFailWithError: %@", error);
}

Its enough for getting current location of user.
Run the app.
First its prompt a message for getting accessibility to use current location(This message will appear  first time only). Click on allow button and  we can see location info in console area.

Note: For running the application on simulator, we need to do some extra setting, because by default simulator location is set to 'None' and this is the reason we are getting error message instead of current location information.
Now select 'Location' under Debug menu option of simulator, and choose 'custom location'. We can see some value for latitude and longitude, it is the position of Apple or Apple store,  we can change latitude and longitude value. Now click on 'Ok' and run the app again.
we can see  latitude and longitude value on console area.

Now we are getting current location of user in the form of latitude and longitude, but is it enough to find address/location by a user?  If i provide my latitude and longitude details to some one , is it possible to find my location for that?
We are getting current location information but its not understand for user. So we are going to convert location info in human readable format.

No need to worry about conversion because Core Location framework has ability to perform this task by CLGeocoder.
CLGeocoder:
The CLGeocoder class provides services for converting coordinate(latitude and longitude) to the user-friendly representation. A user-friendly representation of the coordinate typically consists of the street, city, state, and country information corresponding to the given location, but it may also contain a relevant point of interest, landmarks, or other identifying information. 

 Now back to code and update locationManager: didUpdateLocations: method with below code

 -(void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
    //stop updating locations
    [manager stopUpdatingLocation];
    //get current location
    CLLocation *currentLocation = [locations lastObject];
    NSLog(@"Location latitude - %f",currentLocation.coordinate.latitude);
    NSLog(@"Location longitude - %f", currentLocation.coordinate.latitude);
 
    //convert coodinate to user-friendly representation
    CLGeocoder *geoCoder = [[CLGeocoder alloc] init];
    [geoCoder reverseGeocodeLocation:locations.lastObject completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
        CLPlacemark *placeMark = [placemarks lastObject];
        NSLog(@"name = %@", placeMark.name);
        NSLog(@"address dict = %@",placeMark.addressDictionary);
    }];
}


Run the application again.
Now we can see address details in console area.



Sunday, 15 January 2017

Contact Picker Controller

One of the useful framework provided by Apple is "ContactsUI Framework". ContactUI Framework display user's contact list in a graphical interface.  The ContactUI Framework is useful for display, edit, select and create contact within the app. Before enter in code lets discuss about some important classes of this framework.

CNContactPickerViewController:
CNContactPickerViewController present the entire list of contact to user. This class allows to user to select one or multiple contacts. Its supports both single selection and multi-selection. The app does not need access to the user’s contacts and the user will not be prompted for access. It will only have access to the final selection of the user.

CNContactViewController:
The CNContactViewController is used to display a contact. It can display a new contact, unknown contact, or existing contact.

Now we are ready for display entire list of contacts  within the application.

Here code snippet for  display CNContactPickerViewController
//Create an instance of  CNContactPickerViewController
CNContactPickerViewController *contactController = [[CNContactPickerViewController alloc] init];
//Set the CNContactPickerDelegate
    contactController.delegate = self;
//Present picker controller
    [self presentViewController:contactController animated:YES completion:nil];

Implement the delegate method  for getting details of selected contant.
(In this example we are going to handle onle single selection of contact)

 - (void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact{
            NSLog(@"Given Name = %@",contact.givenName);
           //Get numbers
           NSArray *phoneNumbers= contact.phoneNumbers;
    for(CNLabeledValue *phoneNumber in phoneNumbers){
        if ([phoneNumber isKindOfClass:[CNLabeledValue class]]) {
            NSLog(@"CNLabeledValue - %@", ((CNLabeledValue *)phoneNumber).value);
            id valueType = ((CNLabeledValue *)phoneNumber).value;
            if ([valueType isKindOfClass:[CNPhoneNumber class]]) {
                    NSLog(@"phone number - %@",[valueType valueForKey:@"digits"]);
                    NSLog(@"Country -> %@", [valueType valueForKey:@"countryCode"]);
            }
         }
    }
    [picker dismissViewControllerAnimated:YES completion:nil];
}


// contactPickerDidCancel invoked, when user cancel picker selection
- (void)contactPickerDidCancel:(CNContactPickerViewController *)picker{
    [picker dismissViewControllerAnimated:YES completion:nil];
}


For more detail Click here

Thursday, 5 January 2017

Basic Operators in Swift



Basic Operators

 An operator is a special symbol or phrase that use to check, change, or combine values. For example, the addition operator (+) adds two number. 
let a = 2 + 3
Swift supports most standard C operators and improves several capabilities to eliminate common coding errors.

Unlike C, Swift lets you perform remainder (%) calculations on floating-point numbers. Swift also provides two range operators (a..<b and a...b) not found in C, as a shortcut for expressing a range of values. 


Terminology


Operators are unary, binary, or ternary:
  • Unary operators operate on a single target (such as -a, ++i, --i).
  • Binary operators operate on two targets (such as 2 + 3) and are infix because they appear in between their two targets.
  • Ternary operators operate on three targets. Like C, Swift has only one ternary operator, the ternary conditional operator (a ? b : c).
The values that operators affect are operands. In the expression 1 + 2, the + symbol is a binary operator and its two operands are the values 1 and 2. 

Assignment Operator(=)

Assignment operator initializes or updates the value.
let x = 100   // Declare a  constant variable x with value 100.
var y = 5   //// Declare a  variable y with initial value 5.
y = x        // y is equal to x(100)

Arithmetic Operators

Swift supports the four standard arithmetic operators for all number types:

1. Addition (+)   
   1 + 5   //equals 6
2. Subtraction (-) 
   14 - 4   //equals 10
3. Multiplication (*) 
   4*7    //equals 28 
4. Division (/) 
   30/5    //equals 6
Unlike the arithmetic operators in C and Objective-C, the Swift arithmetic operators do not allow values to overflow by default.


Remainder Operator


The remainder operator (a % b) works out how many multiples of b will fit inside a and returns the value that is left over (known as the remainder).
  9 % 4 // equals 1 
To determine the answer for a % b, the % operator calculates the following equation and returns remainder as its output:
a = (b x some multiplier) + remainder
where some multiplier is the largest number of multiples of b that will fit inside a.


Increment and Decrement Operators

Like C, Swift provides an increment operator (++) and a decrement operator (--) as a shortcut to increase or decrease the value of a numeric variable by 1.

var x = 0;
++x      //Now x equal to 1.
 
Each time you call ++i, the value of i is increased by 1. Essentially, ++i is shorthand for saying i = i + 1. Likewise, --i can be used as shorthand for i = i - 1.
The ++ and -- symbols can be used as prefix operators or as postfix operators. ++i and i++ are both valid ways to increase the value of i by 1. Similarly, --i and i-- are both valid ways to decrease the value of i by 1. 

1. If the operator is written before the variable, it increments the variable before returning its value.  
2. If the operator is written after the variable, it increments the variable after returning its value.

Unary Minus Operator

The sign of a numeric value can be toggled using a prefixed -, known as the unary minus operator: 
let a =10
let minus_a = -a   //minus_a equal to -10
let plus_a = -minus_a  //plus_a equal to 10
The unary minus operator (-) is prepended directly before the value it operates on, without any white space.

Unary Plus Operator

The unary plus operator (+) simply returns the value it operates on, without any change:

 let minus_value = -10
 let sec_value = +minus_value    //sec_value is equal to -10

Compound Assignment Operators

Like C, Swift provides compound assignment operators that combine assignment (=) with another operation. One example is the addition assignment operator (+=): 

Ex : let a = 5;
       a +=4     //now  a equal to 9

The expression a += 2 is shorthand for a = a + 2. Effectively, the addition and the assignment are combined into one operator that performs both tasks at the same time. 
NOTE: The compound assignment operators do not return a value. You cannot write let b = a += 2.

Comparison Operators

Swift supports all standard C comparison operators: 
  1. Equal to (==) 
   2.  Not equal to (!=)
   3. Greater than  (>)
   4. Less than (<)
   5.Greater than or equal to(>=)
   6.Less than or equal to(<=)

NOTE: Swift also provides two identity operators (=== and !==), which you use to test whether two object references both refer to the same object instance.

Ternary Conditional Operator

The ternary conditional operator is a special operator with three parts, which takes the form question ? answer1 : answer2. It is a shortcut for evaluating one of two expressions based on whether question is true or false. If question is true, it evaluates answer1 and returns its value; otherwise, it evaluates answer2 and returns its value.

a==5?b:c
if a equal to 5 than its return b otherwise c. 


Nil Coalescing Operator

The nil coalescing operator (x ?? y) unwraps an optional x if it contains a value, or return a default value y if x is nil. The expression x is always an optional type. The expression y must match the type that is stored inside x.

NOTE: If the value of a is non-nil, the value of b is not evaluated. This is known as short-circuit evaluation. 
EX: let firstColor = "Black"
      let defaultColor = "White"
      let backgroundColor = firstColor ?? defaultColor
     //In this example value of background color is Black


      let firstColor : String?

      let defaultColor = "White"
      let backgroundColor = firstColor ?? defaultColor
     //In this example value of background color is White because firstColor is nil

Range Operators

Swift includes two range operators, which are shortcuts for expressing a range of values.

Closed Range Operator

The closed range operator (a...b) defines a range that runs from a to b, and includes the values a and b. The value of a must not be greater than b.
The closed range operator is useful when iterating over a range in which you want all of the values to be used, such as with a for-in loop:
 for index in 1...5{
          println ("\(index) times 5 is \(index * 5)")
}
OutPut:
// 1 times 5 is 5 
// 2 times 5 is 10 
// 3 times 5 is 15  
// 4 times 5 is 20
// 5 times 5 is 25   





Half-Open Range Operator

The half-open range operator (a..<b) defines a range that runs from a to b, but does not include b. It is said to be half-open because it contains its first value, but not its final value. As with the closed range operator, the value of a must not be greater than b. If the value of a is equal to b, then the resulting range will be empty.
Half-open ranges are particularly useful when you work with zero-based lists such as arrays, where it is useful to count up to (but not including) the length of the list: 

for index in 1..<5{
          println ("\(index) times 5 is \(index * 5)")
}
OutPut:
// 1 times 5 is 5 
// 2 times 5 is 10 
// 3 times 5 is 15  
// 4 times 5 is 20 

Logical Operators

Logical operators modify or combine the Boolean logic values true and false. Swift supports the three standard logical operators found in C-based languages:
 1. Logical Not Operator(!)
      Logical not invert boolean value so that true become false and false become true.

2.Logical And Operator (&&)
     The logical AND operator (a && b) creates logical expressions where both values must be true for the overall expression to also be true.
If either value is false, the overall expression will also be false. In fact, if the first value is false, the second value won’t even be evaluated, because it can’t possibly make the overall expression equate to true. This is known as short-circuit evaluation. 

3. Logical OR Operator (||)

The logical OR operator (a || b) is an infix operator made from two adjacent pipe characters. You use it to create logical expressions in which only one of the two values has to be true for the overall expression to be true.
Like the Logical AND operator above, the Logical OR operator uses short-circuit evaluation to consider its expressions. If the left side of a Logical OR expression is true, the right side is not evaluated, because it cannot change the outcome of the overall expression.



Tuesday, 27 December 2016

CAMediaPicker

CAMediaPicker works like a UIImagePickercontroller. Its allow to select multiple images at a time from photo albums and photo libraries using "Photos Framework". It is a simple library and easy to integrate.

Features of CAMediaPicker
CAMediaPicker has a 4 options to select/add media 
1. MediaPickerSourcePhotoTypeAlbum: Allow to select multiple images at a time form photo albums and libraries.
2. MediaPickerSourceTypeImage:  Click live photo.
3. MediaPickerSourceVideoTypeAlbum: Allow to select a video from video libraries.
4. MediaPickerSourceTypeVideo: Record a live video.

Integration of CAMediaPicker:
1. First add all classes of CAMediaPicker to project.
2. Import "CAMediaManager.h" class to controller.
#import "CAMediaManager.h"
3. Create an instance of CAMediaManager.
CAMediaManager *mediaManager = [CAMediaManager sharedMediaManagerWithRootController:self];
4. Set delegate for CAMediaManage.
mediaManager.mediaPickerDelegate = self;
5. Present CAMediaPicker with setting MediaPickerSourceType
[mediaManager presentMediaPickerControllerWithSource:source];
6. Define delegate methods.

CAMediaPicker return selected media to MediaPickerDelegate.
MediaPickerDelegate contain 3 simple methods.
1.-(void) mediaPicker:(CAMediaManager *)mediaPicker didFailWithAuthorizationStatus:(PHAuthorizationStatus)status;
Above delegate method give current authentication that app can use application is authorized or not  to access photo data.

2. -(void) mediaPicker:(CAMediaManager *)mediaPicker didSelectedAssets:(NSArray *)assetList
Above delegate method give all selected media. It will give multiple images in case of selecting images from photo album, in the rest of the case it will give only one object.

3.-(void) didCancelMediaPicker:(CAMediaManager *)mediaPicker
This delegate method call, if user cancel selection of media.

 Sample code for display photo libraries and photo album(for selecting images)
CAMediaManager *mediaManager = [CAMediaManager sharedMediaManagerWithRootController:self];
    mediaManager.mediaPickerDelegate = self;
    [mediaManager presentMediaPickerControllerWithSource:MediaPickerSourcePhotoTypeAlbum]; 


Sample code for click a photo
CAMediaManager *mediaManager = [CAMediaManager sharedMediaManagerWithRootController:self];
    mediaManager.mediaPickerDelegate = self;
    [mediaManager presentMediaPickerControllerWithSource:MediaPickerSourceTypeImage]; 


Sample code for display list of all videos
 CAMediaManager *mediaManager = [CAMediaManager sharedMediaManagerWithRootController:self];
    mediaManager.mediaPickerDelegate = self;
    [mediaManager presentMediaPickerControllerWithSource:MediaPickerSourceVideoTypeAlbum]; 


Sample code for record a video
CAMediaManager *mediaManager = [CAMediaManager sharedMediaManagerWithRootController:self];
    mediaManager.mediaPickerDelegate = self;
    [mediaManager presentMediaPickerControllerWithSource:MediaPickerSourceTypeVideo];


Delegate methos
-(void) mediaPicker:(CAMediaManager *)mediaPicker didFailWithAuthorizationStatus:(PHAuthorizationStatus)status{
    if (status == PHAuthorizationStatusRestricted) {
        NSLog(@"Application not having access to use photo album and camera");
    }
   
}


-(void) mediaPicker:(CAMediaManager *)mediaPicker didSelectedAssets:(NSArray *)assetList{
     NSLog(@"Selected assets count = %zd", assetList.count);
}

-(void) didCancelMediaPicker:(CAMediaManager *)mediaPicker{
    NSLog(@"Cancel media selection");
}


Click here for download Sample project

Monday, 19 December 2016

Get All Album and Assets

ALAssets library has deprecated in iOS9, and Apple introduce new framework  'Photos Framework' for retrieve assets for display and playback, edit image or video content, or work with collections of assets such as album, moments, and iCloud Shared Album.

Features:
1. Fetching objects and requesting changes
    Class's instance of Photos framework model retrieve assets(images, videos,  and Live Photos), collections of assets(albums or moments), and list of collections(such as album folder or moment clusters). There objects are read only, immutable and contain metadata only.
2. Change observing.
3. Support for Photos app features.
4. Assets and thumbnail loading and caching.
5. Assets content editing.

For details about Photos framework Click here

In this part of blog we will fetch all video assets from device(Photos app).
PHAssets:
All images, videos and live photos in Photos library represented by an instance of PHAssets.
 Instances of PHAsset are immutable.

PHFetchResult:
An ordered list of assets or collections returned from Photos fetch methods.
Photos provide all assets in the in a fetch result.

PHImageManager:
PHImageManager provide methos for retrieving and generating preview thumbnails and full-size image or video data associated with assets instance.

PHAssetCollection:
PHAssetCollection is collection of Photos and Videos assets , such as a moment, user-created album, smart album.

Get All Collection List:

1. Get list of smart albums
PHFetchResult *smartAlbum = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAny options:nil];
    for (PHAssetCollection *collection in smartAlbum){
        NSLog(@"Title Album= %@",collection.localizedTitle);
        [tempArray addObject:collection];
    }


2. Get list of User created albums
PHFetchResult *userAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny options:nil];
    for (PHAssetCollection *collection in userAlbums){
        NSLog(@"Title Album= %@",collection.localizedTitle);
        [tempArray addObject:collection];
    }


Above code return all available list of collection of assets.

Now we can retrieve all assets from collection list.
here code for fetching all assets from collection list

 //initialize a mutable array for contain all assets
self.allImageAssetArray = [[NSMutableArray alloc] init];
 //Initialize an object of image manager
PHImageManager *manager = [PHImageManager defaultManager];
//fetch all image assets from collection list
    PHFetchResult *assetsFetchResult = [PHAsset fetchAssetsInAssetCollection:assetCollectionIdentifier options:nil];
    NSLog(@"Total Count = %zd", assetsFetchResult.count);
    for (PHAsset *asset in assetsFetchResult){

    //Get image from Asset
        [manager requestImageForAsset:asset targetSize:thumbnailSize contentMode:PHImageContentModeAspectFit options:PHImageRequestOptionsResizeModeNone resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
//add image to array
            [self.allImageAssetArray addObject:result];
        }];
    }
//end for loop

Sunday, 27 November 2016

Get list of all Videos

ALAssets library has deprecated in iOS9, and Apple introduce new framework  'Photos Framework' for retrieve assets for display and playback, edit image or video content, or work with collections of assets such as album, moments, and iCloud Shared Album.

Features:
1. Fetching objects and requesting changes
    Class's instance of Photos framework model retrieve assets(images, videos,  and Live Photos), collections of assets(albums or moments), and list of collections(such as album folder or moment clusters). There objects are read only, immutable and contain metadata only.
2. Change observing.
3. Support for Photos app features.
4. Assets and thumbnail loading and caching.
5. Assets content editing.

For details about Photos framework Click here

In this part of blog we will fetch all video assets from device(Photos app).
PHAssets:
All images, videos and live photos in Photos library represented by an instance of PHAssets.
 Instances of PHAsset are immutable.

PHFetchResult:
An ordered list of assets or collections returned from Photos fetch methods.
Photos provide all assets in the in a fetch result.

PHImageManager:
PHImageManager provide methos for retrieving and generating preview thumbnails and full-size image or video data associated with assets instance.

Below chunk of code for retrieving list of video' assets from Photos application.

-(void) getAllVideoAssets{
    NSMutableArray *assets = [[NSMutableArray alloc] init];
    //Fetch all video assets from Photos
    PHFetchResult *assetResults = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeVideo options:nil];
    //get all assets
    for (PHAsset *asset in assetResults){
        NSLog(@"asset type = %zd", asset.mediaType);
        [assets addObject:asset];
    }
    self.allVideoslistArray = [[NSMutableArray alloc] init];
    //create an instance of PHImageManager
    PHImageManager *manager = [PHImageManager defaultManager];
    for(PHAsset *asset in assets){
        //block of code for represent video assets
        [manager requestAVAssetForVideo:asset options:nil resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
            if ([asset isKindOfClass:[AVURLAsset class]]) {
                NSURL *url = (NSURL *)[[(AVURLAsset *)asset URL] fileReferenceURL];
                UIImage *thumbnail = [self createThunbnailImage:url];
                [self.allVideoslistArray addObject:@{@"VideoUrl":url,@"ThumbnailImage":thumbnail, @"VideoAsset":asset}];
            }
        }];
    }//end for loop
}

Sunday, 20 November 2016

Text Animation

A well design  user interface is a key feature of an application.  A end user only interact with UI part an application, so making an  attractive user interface  force user to play with application.
A small small effect like animation help to improve interface design.

In this blog, i am going to display text message with animations.
Click here for download "TextAnimationView" classes.

Create a new project(TextAnimationApplication).
and add downloaded classes to project

Now go to ViewController.m class and import "TextAnimationView.h" file
and declare a variable

TextAnimationView *textAnimationView;                                                        

define below method to add TextAnimationView to ViewController's view

-(void) addTextAnimationView{
//initialize instance
    textAnimationView = [[TextAnimationView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 100) withMessage:@"It's a sample marquee message."];
    [self.view addSubview:textAnimationView];

//Default text appearance animation
    [textAnimationView displayMessageViewWithPresentationType:AnnouncementViewPresentWithCenterAnimation withSpinAnimation:YES];
}


In ViewController.h class declare an IBAction method

-(IBAction)buttonAction:(UIButton *)sender;


Now Switch to main.storyboard file and add UIButtons for different different animations.

In the sample project i added 10 buttons for display text message with 10 different-different animation. Add all buttons with declared method with TouchUpInside event.

Define IBAction method in ViewController.m, file

-(IBAction)buttonAction:(UIButton *)sender{
    switch (sender.tag) {
        case 1:
//display text with scale transform           

[textAnimationView displayMessageViewWithPresentationType:TextAnimationViewPresentWithCenterAnimation withSpinAnimation:YES];
            break;
        case 2:

// display text animation view from top of the screen to declared frame with simple animation.
            [textAnimationView displayMessageViewWithPresentationType:TextAnimationViewPresentWithTopAnimation withSpinAnimation:NO];
            break;

         case 3:
// display text animation view from left of the screen to declared frame with spin animation.
             [textAnimationView displayMessageViewWithPresentationType:TextAnimationViewPresentWithLeftAnimation withSpinAnimation:YES];
            break;
        case 4:

// display text animation view from alpha value animation with spin animation.       
     [textAnimationView displayMessageViewWithPresentationType:TextAnimationViewPresentWithAlpha withSpinAnimation:YES];
            break;
        case 5:

// display text animation view from the bottom of the screen to declared frame with spin animation.
             [textAnimationView displayMessageViewWithPresentationType:TextAnimationViewPresentWithBottomAnimation withSpinAnimation:YES];
            break;
        case 6:

// display text animation view from right of the screen to declared frame with out spin animation.
             [textAnimationView displayMessageViewWithPresentationType:TextAnimationViewPresentWithRightAnimation withSpinAnimation:NO];
            break;
        case 7:

// display text animation view with marquee animation from right
             [textAnimationView setTextMarquee:YES withDirectionType:TextMarqueeFromRight];
            break;
        case 8:

// display text animation view with marquee animation from left
             [textAnimationView setTextMarquee:YES withDirectionType:TextMarqueeFromLeft];
            break;
        case 9:

// display text animation view with marquee animation from Top            [textAnimationView setTextMarquee:YES withDirectionType:TextMarqueeFromTop];
            break;
        case 10:

// display text animation view with character animation(one by one character animation)
             [textAnimationView displayTextWithTypingAnimation:@"It's a sample marquee message."];
            break;
           
        default:
            break;
    }
}


Now run the project and click on buttons for display text message with animations.
Click here for download sample project.