Wednesday, July 24, 2013

Add Custom Button by programming to the tab bar in ios

Here I have given you the code of how to add custom button by programming to the tab bar: -

UIButton *Navigatebtn = [UIButton buttonWithType:UIButtonTypeCustom];

    Navigatebtn.frame=CGRectMake(20,2,64,30);


    UIImage *btnImg=[UIImage imageNamed:@"cancel.png"];


    [Navigatebtn setBackgroundImage:btnImg forState:UIControlStateNormal];


    [Navigatebtn addTarget:self action:@selector(getStylistData) forControlEvents:UIControlEventTouchUpInside];


    UIBarButtonItem *barItem=[[UIBarButtonItem alloc]initWithCustomView:Navigatebtn];
    self.navigationItem.rightBarButtonItem=barItem;


Here is the functions which can be attached with it :-

-(void) getStylistData
{
  ViewController1 *browController =[[ViewController1 alloc]init];


    [self.navigationController pushViewController:browController animated:YES];
}