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

      

  • 相关阅读:
    相机篇
    ValueAnimator动画跳过中间过程的问题
    android 双向文字问题
    android让xml布局的底部跟随软键盘
    给fragment设置进入和退出动画
    android布局控件的LayoutParams
    注意点
    关于与条件判断中的顺序
    栈的反转
    从尾到头打印链表
  • 原文地址:https://www.cnblogs.com/qingzZ/p/14040860.html
Copyright © 2011-2022 走看看