用segment设置导航栏

来源:互联网 发布:软件打包工具 编辑:程序博客网 时间:2024/05/22 02:23
   //设置导航条titleView    UISegmentedControl *titleV = [[UISegmentedControl alloc] initWithItems:@[@"充值", @"提现"]];    [titleV setTintColor:[UIColor themecolorWithHexCode]];    titleV.frame = CGRectMake(0, 0, self.view.bounds.size.width * 0.5 - 40, 30);    //文字设置    NSMutableDictionary *attDic = [NSMutableDictionary dictionary];    attDic[NSFontAttributeName] = [UIFont fontWithName:@"NotoSansHans-Thin" size:16];;    attDic[NSForegroundColorAttributeName] = [UIColor blackColor];        NSMutableDictionary *attDicSelected = [NSMutableDictionary dictionary];    attDicSelected[NSFontAttributeName] = [UIFont fontWithName:@"NotoSansHans-Thin" size:16];;    attDicSelected[NSForegroundColorAttributeName] = [UIColor whiteColor];        [titleV setTitleTextAttributes:attDic forState:UIControlStateNormal];    [titleV setTitleTextAttributes:attDicSelected forState:UIControlStateSelected];    //事件    titleV.selectedSegmentIndex = 0;    [titleV addTarget:self action:@selector(titleViewChange:) forControlEvents:UIControlEventValueChanged];    self.navigationItem.titleView = titleV;

0 0
原创粉丝点击