关闭

textView中的placeholderLabel

72人阅读 评论(0) 收藏 举报

 _explainView = [[UITextView alloc]init];

       // _explainView.backgroundColor = [UIColor colorWithRed:236.0/255 green:241.0/255 blue:238.0/255 alpha:1];

        _explainView.backgroundColor = [UIColor whiteColor];

        _explainView.delegate = self;

        _explainView.font = [UIFont systemFontOfSize:18];

        _explainView.layer.borderColor = [UIColor colorWithRed:236.0/255 green:241.0/255 blue:238.0/255 alpha:1].CGColor;

        _explainView.layer.borderWidth = 1.0;

        [cell.contentView addSubview:_explainView];

        [_explainView mas_makeConstraints:^(MASConstraintMaker *make) {

            make.left.mas_equalTo(_explainLabel.mas_right).offset(5);

            make.top.mas_equalTo(imageView.mas_top);

            make.bottom.mas_equalTo(-10);

            make.right.mas_equalTo(-10);

        }];

        

        _placeHolderView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"vgz-sp-wplq6"]];

        [_explainView addSubview:_placeHolderView];

        [_placeHolderView mas_makeConstraints:^(MASConstraintMaker *make) {

            make.left.mas_equalTo(0);

            make.top.mas_equalTo(10);

            make.size.mas_equalTo(CGSizeMake(28/2, 31/2));

        }];

//

        _placeholderLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 150, 40)];

        _placeholderLabel.textAlignment = NSTextAlignmentLeft;

        _placeholderLabel.font = [UIFont systemFontOfSize:18];

        _placeholderLabel.text = @"请输入任务完成详细说明";

        _placeholderLabel.textColor = [UIColor grayColor];

        [_explainView addSubview:_placeholderLabel];

        [_placeholderLabel mas_makeConstraints:^(MASConstraintMaker *make) {

            make.left.mas_equalTo(_placeHolderView.mas_right).offset(1);

           // make.centerY.mas_equalTo(_placeHolderView.mas_centerY);

            make.size.mas_equalTo(CGSizeMake(140, 20));

            make.top.mas_equalTo(10);

            

        }];

        

        

        

    }

    return cell;

}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section==0) {

        

        return 60;

    }else if (indexPath.section==1){

        return 60;

    }else if (indexPath.section==2){

        return 170;

        

    }

    return 80;

    

}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    return 20;

    

}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, tableView.tableHeaderView.frame.size.height)];

    view.backgroundColor = [UIColor colorWithRed:230.0/255 green:238.0/255 blue:233.0/255 alpha:1];

    return view;

    

}


-(void)textViewDidChange:(UITextView *)textView{

    if (textView.text.length ==0) {

        _placeholderLabel.text = @"请输入内容";

        

           }

    else{

        _placeholderLabel.text=@"";

        

//        _placeHolderView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@""]];

        

        _placeHolderView.hidden = YES;

        

    }

}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:45007次
    • 积分:2063
    • 等级:
    • 排名:第19137名
    • 原创:167篇
    • 转载:0篇
    • 译文:0篇
    • 评论:4条
    文章分类
    最新评论