Monday, May 6, 2013

Changing Text of Label Animated Using Blocks

Hi friends,

Many a times when I was a newbie in iOS development, I had to face many problems regarding improving the look and feel of the UI elements. my designer too was a novice in mobile apps environment. At that time whenever I wanted  to develop a good looking user interface, I had to do a lot of RnD(a prestigious synonym for googling).

Below I will provide you some of the code snippets which I used at that time to make the interface look cool.

Note: You need to add QuartzCore framework to your project, along with also import <QuartzCore/QuartzCore.hin your file.

1. Snippet for adjusting the corner radius , or customising the rounded corner of UI elements.


   a. For setting the corner radius or making the corner of the UI element rounded you need just to add the following line to your existing code.
    
    myView.layer.cornerRadius = 5;
b. For setting the border width and border color of your UI element, please add the following lines to your existing code.


    myView.layer.borderWidth = 2;
    myView.layer.borderColor = [UIColorlightGrayColor].CGColor;

2. Snippet for adding shadow effects to UI elements.

Often you might have seen the iPhone screens having buttons and Images having a translucent shadow behind them, that effect you can have in 2 ways, either you must have a good designer who can make you an image holder image having the same effects. or the second approach is quite easy and also memory efficient, as you will be using only one UI-element(no extra image to show the shadow effect). 
Just add the following line of codes to your file and see the effect.
     myView.layer.shadowOpacity=0.8;
     myView.layer.shadowColor = [[UIColor lightGrayColor] CGColor];
     myView.layer.shadowOffset=CGSizeMake(0, 0); 
     myView.layer.shadowRadius=3;

3.Snippet for changing the text of the UILabel animated using Blocks


[UIViewanimateWithDuration:1.3
                     animations:^{
                         lbl_MyLabel.alpha = 0.0f;
                         lbl_MyLabel.text = [self.dictFromLastView objectForKey:@"titleLbl"];
                         lbl_MyLabel.alpha = 1.0f;
                     }];


No comments:

Post a Comment