31 Mar 2017

Adding a custom View (With a label & a Button)In navigation Bar rightBarButtonItem...


Adding a custom View (With a label & a Button)In navigation Bar rightBarButtonItem...

  
    UIView *containView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 40)];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0,65, 40)];
    label.text = @"Out Of India";
    label.textAlignment = 1;
    label.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:11.0];
    label.textColor = [UIColor whiteColor];
    [containView addSubview:label];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(66, 0, 30, 40);
    btn.backgroundColor = [UIColor greenColor];
    [btn setImage:[UIImage imageNamed:@"check.png"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(checkSelection:) forControlEvents:UIControlEventTouchUpInside];
    [containView addSubview:btn];
    
    UIBarButtonItem *Item  = [[UIBarButtonItem alloc]initWithCustomView:containView];
    self.navigationItem.rightBarButtonItem = Item;

No comments:

Post a Comment

Recent Posts

Codable demo

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