24 Jun 2017

Adding Title, Left & Right bar buttons in navigationController...


Adding Title, Left & Right bar buttons in navigationController...



- (void)viewDidLoad {

 self.title=@"VC Title";
[self showbackButton];
[self rightButton];

}


-(void)showbackButton
{

    UIButton *button =  [UIButton buttonWithType:UIButtonTypeCustom];
    button.titleLabel.font =[UIFont fontWithName:@"FontAwesome" size:20.0];
    [button setFrame:CGRectMake(0, 2, 30, 40)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"\uf104" style:UIBarButtonItemStylePlain target:self action:@selector(backButtonClicked:)];


}

// if we use fontwesome add FontAwesome.ttf file

-(void)rightButton
{

rightButton =  [[UIBarButtonItem alloc]initWithTitle:@"\uf0c9" style:UIBarButtonItemStylePlain target:self action:@selector(menuButtonClicked)];
    [rightButton setTitleTextAttributes:@{
                    NSFontAttributeName: [UIFontfontWithName:@"Fontawesome" size:15.0],
         NSForegroundColorAttributeName:[UIColor whiteColor]
} forState:UIControlStateNormal];

  self.navigationItem.rightBarButtonItems=@[rightButton];

}

No comments:

Post a Comment

Recent Posts

Codable demo

Link: https://www.dropbox.com/s/kw7c1kgv1628bh7/codableDemo.zip?dl=0