ios---nav调整item间距,添加按钮设置按钮的高

    UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];

    //调整items间距

    space.width = 20;

     

    _attentionBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40, 20)];

    [_attentionBtn setTitle:@"关注" forState:UIControlStateNormal];

    [_attentionBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

    _attentionBtn.titleLabel.font = JhFontsize(12);

    [_attentionBtn.layer setCornerRadius:5]; //设置矩圆角半径

  [_attentionBtn addTarget:self action:@selector(ClickAttentionBtn:) forControlEvents:UIControlEventTouchUpInside];

    

    UIView *btnView = [[UIView alloc] initWithFrame:_attentionBtn.bounds];

    [btnView addSubview:_attentionBtn];


    UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithCustomView:btnView]; 

    

    self.navigationItem.rightBarButtonItems@[item1,space,item2]


           






猜你喜欢

转载自blog.csdn.net/iotjin/article/details/80396736