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

      

  • 相关阅读:
    笔记7-7
    输出九九乘法表
    eclipse配置Maven——菜鸟篇
    IOC和AOP使用扩展之AOP详解实现类
    --------Hibernate框架之双向多对多关系映射
    易买网----------有感
    有关于TreeSet的自我理解
    爱学习当当网----图片的切换,书栏的循环滚动
    有关于购物车买买买?剁手吧
    致童年,一生都无法忘记的技能
  • 原文地址:https://www.cnblogs.com/qingzZ/p/14040860.html
Copyright © 2011-2022 走看看