Showing posts with label alpha. Show all posts
Showing posts with label alpha. Show all posts

Monday, May 3, 2010

How to Create Delayed Tab Change

Not sure, if it's a good idea, but this is how you create "smooth" tab view changes:
#pragma mark - TabBar controller delegate
- (void)tabBarController:(UITabBarController*)tbc
  didSelectViewController:(UIViewController*)newSelection
{
    [UIView beginAnimations:@"myTabFade" context:nil];
    [UIView setAnimationDuration:0.5];
    for (UIViewController* vc in tbc.viewControllers)
        vc.view.alpha = (vc==newSelection) ? 1 : 0;
    [UIView commitAnimations];  
}
User will notice something happened as expected and your app will look either stylish or slow, depending on your graphics, UI design and overall implementation.

Be careful, style is not an easy thing to achieve!

Thursday, February 4, 2010

How to Use RGB Values to Show a Non-white Color

This one was really annoying! In every other system I've used, and there's a few, RGB color values (Red - Green - Blue) were from 0 to 255.

iPhone RGB values are from 0 to 1. Using something like (0, 0, 255) gives no warnings what-so-ever. Just silently accepts whatever values you give it and happily tries its best to show you - WHITE !!!

As a sample, here's beige color:

myView.backgroundColor = [UIColor colorWithRed:0.96 green:0.96 blue:0.86 alpha:1];


Please note that alpha value 0 (zero) means transparent. If your alpha is 1 (one), you will see color of object below your component, regardless whether you used correct RGB values or not.

That wasn't happy debugging at all.