iOS自定义NavigationBar

来源:互联网 发布:mac itunes铃声 编辑:程序博客网 时间:2024/04/30 06:52

最近忙着搭建页面,昨天网上做选址界面的时候,需要在NavigationBar的title位置放一个UISegmentControl,

于是学习了一下怎样处理,现在学会了与大家分享,放什么控件都行,只要是UIView的子类~

万变不离其宗~ 


        UISegmentedControl *segmentControl = [[UISegmentedControl alloc]initWithFrame:CGRectMake(0, 0, 150, 30)];        segmentControl.tintColor =  [UIColor whiteColor];        [segmentControl insertSegmentWithTitle:@"按地市" atIndex:0 animated:YES];        [segmentControl insertSegmentWithTitle:@"按拼音" atIndex:1 animated:YES];        segmentControl.selectedSegmentIndex = 0;        self.navigationItem.titleView = segmentControl;


0 0