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

ios 导航添加多个按钮

作者: 你又脸红了i | 来源:发表于2018-11-09 15:26 被阅读0次

    //第一个按钮

        UIButton *but = [UIButton buttonWithType:UIButtonTypeCustom];

        [butaddTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];

        [butsetImage:[UIImage imageNamed:@"btn_pause"] forState:UIControlStateNormal];

        [butsizeToFit];

        UIBarButtonItem *Item = [[UIBarButtonItem alloc] initWithCustomView:but];

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

    //    fixedSpaceBarButtonItem.width = 22;

        //第二个

        UIButton *but1 = [UIButton buttonWithType:UIButtonTypeCustom];

        [but1addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];

        [but1setImage:[UIImage imageNamed:@"btn_play"] forState:UIControlStateNormal];

        [but1sizeToFit];

        UIBarButtonItem *Item1 = [[UIBarButtonItem alloc] initWithCustomView:but1];

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

    //    fixed.width = 22;

        //第三个

        UIButton *set2 = [UIButton buttonWithType:UIButtonTypeCustom];

        [set2addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];

        [set2setImage:[UIImage imageNamed:@"btn_play"] forState:UIControlStateNormal];

        [set2sizeToFit];

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

        self.navigationItem.rightBarButtonItems  =@[Item,Item1,item2];

    相关文章

      网友评论

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

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