美文网首页
navigationBar相关

navigationBar相关

作者: 小布丁儿 | 来源:发表于2015-12-10 11:29 被阅读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.LeftBarButtonItem = setRightBarButtonItem;
  • UIImageView -> UIButton -> UIBarButtonItem -> self.navigationItem

  • 通过initWithCustomView方法,实现UIButton -> UIBarButtonItem

怎么在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;
  • JRSegmentControl -> self.navigationItem.titleView
    • 通过赋值的方式 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

  • 通过addSubView的方式
    • [self.navigationController.navigationBar addSubview:contorl];

相关文章

  • NavigationBar相关

    如何在navigationBar加个Left,这些控件本身只能在固定位置上 先上代码 UIImage -> UIB...

  • navigationBar相关

    怎么在navigationBar加个Left(左右) .这些控件本身只能在固定位置上 //设置Button的背景图...

  • navigationBar相关

    如何在navigationBar上加一个left/rightitem (Button),这种item只能有固定的位...

  • navigationBar相关

    怎么在navigationBar加个Left,这些控件本身只能在固定位置上 先上代码 UIImageView ->...

  • NavigationBar 相关

    修改Navigation Bar的按钮/文字颜色 在Storyboard中Navigation View Cont...

  • IOS NavigationBar相关

    怎么在navigationBar加个Left,这些控件本身只能在固定位置上? 先上代码 UIImage -> UI...

  • Swift UINavigationController

    相关链接 iOS 处理 navigationBar.titleTextAttributes 属性时机(Swift)...

  • Navigationbar的相关设置

    1.navigationbar上的左右按钮的位置的改变 如果想要图示1的效果代码如下: 如果想要图示2的效果代码如...

  • iOS-navigationBar相关

    怎么在navigationBar加个Left ,这些控件本身只能在固定位置上 先上代码 UIImageView -...

  • 理清NavigationBar的相关设置

    我在 解决navigationBar跳转出现的黑色块 这篇文章里面介绍了设置 NavigationBar 透明的方...

网友评论

      本文标题:navigationBar相关

      本文链接:https://www.haomeiwen.com/subject/lccyhttx.html