NavigationBar

2015-12-10  本文已影响0人  徐大拿

怎么在navigationBar加个Left ,这些控件本身只能在固定位置上

先上代码

UIImage* backImage = [UIImage imageNamed:@"nav_order_more"];
    CGRect backframe = CGRectMake(0,0,30,8);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.font=[UIFont systemFontOfSize:13];
    [backButton addTarget:self action:@selector(doClickBackAction) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem* setRightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.rightBarButtonItem = setRightBarButtonItem

怎么在navigationBar加个Center,这些控件本身只能在固定位置上

JRSegmentControl *segment = [[JRSegmentControl alloc] initWithFrame:CGRectMake(0, 0, self.itemWidth* self.viewControllers.count, self.itemHeight) titles:self.titles]; 
segment.backgroundColor = self.segmentBgColor; 
segment.indicatorViewColor = self.indicatorViewColor; 
segment.delegate = self; 
self.navigationItem.titleView = segment;

如何在navigationBar在任意位置加空间

UISegmentedControl * contorl = [[UISegmentedControl alloc] initWithItems:@[@"全部",@"待收货",@"待评价"]];
 contorl.frame = CGRectMake([UIScreen mainScreen].bounds.size.width/2-150/2, 2, 150, 40);
 [contorl addTarget:self action:@selector(clickSegment:) forControlEvents:UIControlEventValueChanged]; 
//默认选择为第一个 contorl.selectedSegmentIndex = 0; 
[self.navigationController.navigationBar addSubview:contorl];

UISegmentedControl -> self.navigationController.navigationBar

上一篇 下一篇

猜你喜欢

热点阅读