UISegmentedControl in the Navigation Bar with the Back button

后端 未结 2 1398
悲&欢浪女
悲&欢浪女 2021-02-02 15:03

I\'m adding a UISegmentedControl to the Navigation bar programatically where the titleView should be. But as Apple docs have mentioned under titl

2条回答
  •  离开以前
    2021-02-02 15:54

    Try this

    Remove this line --- > self.navigationItem.leftBarButtonItem = nil;

    Add this instead

    UISegmentedControl *statFilter = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Filter_Personnal", @"Filter_Department", @"Filter_Company", nil]];
    [statFilter setSegmentedControlStyle:UISegmentedControlStyleBar];
    [statFilter sizeToFit];
    self.navigationItem.titleView = statFilter;
    

    Only change is I have added this line :

    [statFilter sizeToFit];
    

    Hope this Helps !!!

提交回复
热议问题