• 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

  • 相关阅读:
    云服务器配置
    linux云服务器的配置
    Python进阶练习与爬取豆瓣T250的影片相关信息
    实时爬取疫情动态变化并进行可视化展示
    python基础学习
    异步实现用户名的校验
    人月神话读书笔记(一)
    第三周学习进度博客
    CentOS7.4下编译Hadoop-2.7.6
    Linux 内存使用率
  • 原文地址:https://www.cnblogs.com/Qingqingyang/p/4969889.html
Copyright © 2020-2023  润新知