zoukankan      html  css  js  c++  java
  • 解决导航条上自定义按钮不能靠左或靠右的问题

     _newsBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        [_newsBtn setImage:[UIImage imageNamed:@"home_news"] forState:UIControlStateNormal];

        _newsBtn.frame = CGRectMake(0, 0, 30, 30);

        [_newsBtn addTarget:self action:@selector(newsbtnSysClike) forControlEvents:UIControlEventTouchUpInside];

        //用于把自定义的按钮与导航条的联系起来

        UIBarButtonItem *newsBtnItem = [[UIBarButtonItem alloc]initWithCustomView:_newsBtn];

        self.navigationItem.leftBarButtonItem = newsBtnItem;

        //解决按钮不靠左 靠右的问题.

        UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace

                                                                                       target:nil action:nil];

        nagetiveSpacer.width = -10;//这个值可以根据自己需要自己调整

        self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, newsBtnItem];

  • 相关阅读:
    Linux中的计算器(bc)
    在Linux中显示日历(cal)
    在Linux中显示日期(date)
    Linux中的注销当前用户
    Linux中的提示符
    在Linux中启动X Window
    硬盘知识
    划分Linux分区
    Linux中的关机
    hdu4424 Conquer a New Region 并查集/类似最小生成树
  • 原文地址:https://www.cnblogs.com/wenqian/p/6019461.html
Copyright © 2011-2022 走看看