• 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)];
    }
    

      

  • 相关阅读:
    java基础知识复习
    css打对勾
    jqgrid显示一行的详情
    jqgrid在colModel中多次调用同一个字段值
    software architecture slide 2
    software architecture slide 1
    英语冷笑话
    单复同形
    量子力学为什么翻译成quantum,或者说quantum为什么翻译成量子力学
    To YOU
  • 原文地址:https://www.cnblogs.com/qingzZ/p/14040860.html
Copyright © 2020-2023  润新知