zoukankan      html  css  js  c++  java
  • OC 添加导航栏item

    /**
     * 设定右侧按钮方法
     */
    - (void)createMakeBtn{
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 70, 40)];
        button.backgroundColor = UIColor.systemGreenColor;
        self.makeBtn = button;
        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        [button.titleLabel setFont:[UIFont systemFontOfSize:14 weight:(UIFontWeightRegular)]];
        [button addTarget:self action:@selector(clickMakeBtn) forControlEvents:UIControlEventTouchUpInside];
        button.userInteractionEnabled = NO;
        button.showsTouchWhenHighlighted = NO;
        ///显示的item
        UIBarButtonItem * item = [[UIBarButtonItem alloc] initWithCustomView:button];
        ///间距
        UIBarButtonItem *fixItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
        self.navigationItem.rightBarButtonItems = @[fixItem, item];
        
        [self updateCreateBtnStatus];
    }
    
    /// 更新制作按钮的显示状态
    - (void)updateCreateBtnStatus{
        if (self.selectedAssetArr.count > 0) {
            self.makeBtn.backgroundColor = UIColor.blueColor;
            self.makeBtn.userInteractionEnabled = YES;
        }else{
            self.makeBtn.backgroundColor = UIColor.grayColor;
            self.makeBtn.userInteractionEnabled = NO;
        }
        NSString *selectedStr = [NSString stringWithFormat:@"制作(%lu/%d)", (unsigned long)self.selectedAssetArr.count, self.maxSelectedPic];
        [self.makeBtn setTitle:selectedStr forState:(UIControlStateNormal)];
    }
    

      

  • 相关阅读:
    前言
    实用逆袭课【时间管理、记忆训练、工作效率、人际社交】
    读书确实是一辈子的事
    求职宝典(笔记不详细,但你自己看完消化了真的受用)
    重新认识【时间、金钱、自我、人际关系】
    即兴演讲不是即兴
    大数据和AI的未来畅想
    女性30的思考1
    第四课 人际关系
    第三课 干好工作
  • 原文地址:https://www.cnblogs.com/qingzZ/p/14040860.html
Copyright © 2011-2022 走看看