zoukankan      html  css  js  c++  java
  • ios UITextView 提示文本

    定义两个UITextView,一个用于输入文本,一个用于显示提示信息,当输入文本为空时显示提示信息,否则不显示提示信息。

            //6.3.1文字内容提示
            _contentTextViewTip = [[UITextView alloc] initWithFrame:CGRectMake(12, 5, WIDTH_SCREEN - 12 - 12, 105)];
            if (_contentTextViewTip != nil)
            {
                _contentTextViewTip.text = POST_CONTENT_TIP;
                _contentTextViewTip.font = [UIFont systemFontOfSize:16.0];
                _contentTextViewTip.userInteractionEnabled = NO;
                _contentTextView.delegate = self;
                _contentTextViewTip.textColor = [[UIColor alloc] initWithRed:160/255.0 green:160/255.0 blue:160/255.0 alpha:1.0];
                [scrollView addSubview:_contentTextViewTip];
            }
            
            //6.3.2文字内容文本框
            _textViewRect = CGRectMake(12, 5, WIDTH_SCREEN - 12 * 2, 105);
            if(_contentTextView != nil)
            {
                _contentTextView = [[UITextView alloc]initWithFrame:_textViewRect];
                _contentTextView.backgroundColor = [UIColor clearColor];
                _contentTextView.font = [UIFont systemFontOfSize:16.0];
                //_contentTextView.textColor = [[UIColor alloc] initWithRed:160/255.0 green:160/255.0 blue:160/255.0 alpha:1.0];
                //_contentTextView.text = @"说点什么~";
                [_contentTextView setScrollEnabled:YES];
                _contentTextView.userInteractionEnabled = YES;
                _contentTextView.showsVerticalScrollIndicator = YES;
                CGSize size = CGSizeMake(WIDTH_SCREEN - 12 * 2, 600.0f);
                [_contentTextView setContentSize:size];
                _contentTextView.returnKeyType = UIReturnKeyDone;
                _contentTextView.keyboardType = UIKeyboardTypeDefault;
                _contentTextView.delegate = self;
                [scrollView addSubview:_contentTextView];
            }

    #pragma mark _contentTextView Delegate
    /**
     *  文字改变时触发的事件
     */
    - (void)textViewDidChange:(UITextView *)textView
    {
        NSLog(@"textViewDidChange:%@", textView.text);
        if (textView == _contentTextView)
        {
            
            if ([textView.text isEqualToString:@""])
            {
                _contentTextViewTip.alpha = 1;
            }
            else
            {
                _contentTextViewTip.alpha = 0;
            }
        }
    }


  • 相关阅读:
    17岁韩寒在CCTV《对话》舌战群吊的视频
    在线LaTex编辑器
    PowerShell 点滴记录
    程序阅读理解题目(高中语文版,附答案)
    jQuery Validate 应用
    ASP.net MVC 向子视图传递数据
    分库分表(sharding)后主键全局唯一性的解决方案
    Ajax局部刷新例子
    限制 Flash 在指定域名/网址中播放 (Flash 防盗链)
    javascript实现二级联动下拉框
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/4185584.html
Copyright © 2011-2022 走看看