美文网首页
rightBarButtonItems距离屏幕边距自定义

rightBarButtonItems距离屏幕边距自定义

作者: frola_ | 来源:发表于2017-11-06 10:10 被阅读0次

    建立rightBarButtonItems数组定义negativeSpacer的宽度来调整button距离屏幕的距离

    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 16, 16)];
    [button setImage:[UIImage imageNamed:@"myApply_search"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(searchButtonClick) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
                                           initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                           target:nil action:nil];
    negativeSpacer.width = 5;
    self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:negativeSpacer,item,nil];
    

    相关文章

      网友评论

          本文标题:rightBarButtonItems距离屏幕边距自定义

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