Sunday, May 22, 2011

Search Bar with Clear Background and its Properties

Hello friends,

Today we will go further with the Search Bar's clear back ground and will look at its property set with programmatically.

Follow the following steps:
UISearchBar* mySearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0,160,320,40)];
    mySearchBar.showsCancelButton = NO;
    mySearchBar.userInteractionEnabled = YES;
    mySearchBar.backgroundColor = [UIColor clearColor];
    mySearchBar.tintColor = [UIColor whiteColor];
    mySearchBar.showsScopeBar = NO;
    [self.view addSubview:mySearchBar];
   
    for (UIView *subview in mySearchBar.subviews)
    {
        if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")])
        {
            [subview removeFromSuperview];
            break;
        }
    } 

Have a Nice Day.. :-)

No comments:

Post a Comment