zoukankan      html  css  js  c++  java
  • UITextView默认文字提示

    在UITextField中自带placeholder属性,可以用于提示输入框信息。但是UITextView并不具备此功能
    介绍两种方法来实现:
    第一种:
    初始化UITextView
    //首先定义UITextView
    UITextView *textView = [[UITextView alloc] init];
    textView.font = [UIFont systemFontOfSize:14];
    textView.frame =CGRectMake(10, 0, cell.contentView.bounds.size.width-20, side);
    textView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    textView.backgroundColor = [UIColor whiteColor];
    [cell.contentView addSubview:textView];
    textView.hidden = NO;
    textView.delegate = self;
    //其次在UITextView上面覆盖个UILable,UILable设置为全局变量。
    uilabel.frame =CGRectMake(17, 8, cell.contentView.bounds.size.width - side+10, 20);
    uilabel.text = @"请填写审批意见...";
    uilabel.enabled = NO;//lable必须设置为不可用
    uilabel.backgroundColor = [UIColor clearColor];
    [cell.contentView addSubview:uilabel];
    实现UITextView的代理
    -(void)textViewDidChange:(UITextView *)textView
    {
    self.examineText = textView.text;
    if (textView.text.length == 0) {
    uilabel.text = @"请填写审批意见...";
    }else{
    uilabel.text = @"";
    }
    }
  • 相关阅读:
    setTimeOut与循环闭包问题
    ES6----class用法
    JS------对象的继承方式
    JavaScript对象 -构建
    nodejs异步---Async
    mongdb位置索引
    mongodb 索引3
    mongod 索引2
    mongodb 索引1
    3 C++数据类型
  • 原文地址:https://www.cnblogs.com/guoxiaoqian/p/4558168.html
Copyright © 2011-2022 走看看