zoukankan      html  css  js  c++  java
  • UI- UITextView

    //  ViewController.m

    //  fiedl

    //  Created by cqy on 15/11/16.

    //  Copyright (c) 2015年 cqy. All rights reserved.

    #import "ViewController.h"

    @interface ViewController ()<UITextViewDelegate>

    @end

    @implementation ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        

        

        UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 70, 80, 30)];

        textView.backgroundColor = [UIColor greenColor];//设置背景颜色

        textView.editable = YES; //是否允许编辑内容,默认为“YES”

        textView.scrollEnabled =  YES; //当文字超过视图的边框时是否允许向下滑动,默认为“YES”

        textView.bounces = YES;

        

       textView.font = [UIFont fontWithName:@"Arial" size:21];//设置字体名字和字体大小;

        textView.returnKeyType = UIReturnKeyRoute;//return键的类型

        textView.keyboardType =   UIKeyboardTypeURL;//键盘类型

        textView.textAlignment =NSTextAlignmentLeft;//文本显示格式的位置,默认为居左

        textView.layer.borderColor = [UIColor blackColor].CGColor;

        textView.layer.borderWidth = 3;

        textView.layer.cornerRadius = 10;

        textView.layer.masksToBounds = YES;

        textView.delegate = self;//设置代理方法的实现类

        textView.text = @"你真美 ...";//设置显示的文本内容

        textView.returnKeyType =UIReturnKeyDone;

        [self.view addSubview:textView];

        

        

        

        

        // Do any additional setup after loading the view, typically from a nib.

    }

    -(BOOL)textViewShouldBeginEditing:(UITextView *)textView{

        //将要开始编辑

        NSLog(@"将要开始编辑...");

        return YES;

    }

    -(BOOL)textViewShouldEndEditing:(UITextView *)textView{

        //将要结束编辑

        NSLog(@"将要结束编辑...");

        return YES;

    }

    -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{

        //内容将要发生改变编辑

        NSLog(@"--%@--",text);

        if([text isEqualToString:@" "]){

            [textView resignFirstResponder];

        }

        return YES;

    }

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

        //开始编辑

        NSLog(@"--->%@",textView.text);}

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

        //结束编辑

        NSLog(@"结束编辑...");

    }

     - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

    @end

  • 相关阅读:
    C#客户端程序Visual Studio远程调试
    VS2013如何转成VS2010且不会出现此项目与Visual Studio的当前版本不兼容的报错
    Windows控件的命名规范
    VS2010中如何将exe文件生成setup安装文件
    Altium Designer Summer 09的操作
    Java SE(一)——java基础
    Java SE(二)——java语言基础
    重写与重载的区别
    Altium Designer Summer 09——元器件的封装
    Java SE(四)——java 面向对象入门
  • 原文地址:https://www.cnblogs.com/Qingqingyang/p/4969889.html
Copyright © 2011-2022 走看看