ios UITextView 提示文本

來源:互聯網
上載者:User

標籤:style   blog   io   ar   color   os   sp   on   2014   

定義兩個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;        }    }}


ios UITextView 提示文本

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.