美文网首页
ios 导航条添加多个按钮

ios 导航条添加多个按钮

作者: 一个萝卜X个坑 | 来源:发表于2018-07-18 13:50 被阅读481次
        UIButton *informationCardBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [informationCardBtn addTarget:self action:@selector(RightBtnCLick:) forControlEvents:UIControlEventTouchUpInside];
        [informationCardBtn setImage:[UIImage imageNamed:@"nav_information"] forState:UIControlStateNormal];
        
        [informationCardBtn sizeToFit];
        UIBarButtonItem *informationCardItem = [[UIBarButtonItem alloc] initWithCustomView:informationCardBtn];
        
        
        UIBarButtonItem *fixedSpaceBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
        fixedSpaceBarButtonItem.width = 22;
        
        
        UIButton *settingBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [settingBtn addTarget:self action:@selector(RightBtnCLick:) forControlEvents:UIControlEventTouchUpInside];
        [settingBtn setImage:[UIImage imageNamed:@"nav_settings"] forState:UIControlStateNormal];
        [settingBtn sizeToFit];
        UIBarButtonItem *settingBtnItem = [[UIBarButtonItem alloc] initWithCustomView:settingBtn];
        
        
        
        self.navigationItem.rightBarButtonItems  = @[informationCardItem,fixedSpaceBarButtonItem,settingBtnItem];
    

    相关文章

      网友评论

          本文标题:ios 导航条添加多个按钮

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