zoukankan      html  css  js  c++  java
  • UITextView

    一、由于IOS中的UITextField不支持文本换行,在需要换行的时候。我们可以用UITextView来解决这一问题。
     
    二、创建步骤
    1、初始化并设置位置和大小
    UITextView *textView = [[UITextViewalloc] initWithFrame:CGRectMake(20, 20, 100, 80)];
    2、设置相关的属性
    textView.backgroundColor = [UIColor grayColor];
    textView.editable = NO;//是否允许编辑
         textView.scrollEnabled = NO;//是否允许滚动
         textView.bounces = NO;//弹簧效果
    textView.layer.borderColor = [UIColor redColor].CGColor;//边框颜色
        textView.layer.borderWidth = 1;//边框粗细
       
        textView.layer.cornerRadius = 10;//设置圆角,如果想要原型,需要设置为高的一半
       
        textView.layer.masksToBounds = YES;//限制输入内容是在边框里显示。
       
    3、代理
    textView.delegate = self;//设置代理
    textView.returnKeyType = UIReturnKeyDone;
     
    4、加入父视图
    [self.view addSubview:textView];
     
    三、相关的属性
    1textview.editable = YES;        //是否允许编辑内容,默认为“YES”
    2、textview.scrollEnabled= NO;    //当文字超过视图的边框时是否允许滑动,默认为“YES”
    3、textView.bounces = NO;//弹簧效果
       
    4、textView.layer.borderColor = [UIColor redColor].CGColor;//边框颜色
    5、textView.layer.borderWidth = 1;//边框粗细
       
    6、textView.layer.cornerRadius = 10;//设置圆角,如果想要原型,需要设置为高的一半
    7、textView.layer.masksToBounds = YES;//限制输入内容是在边框里显示。
     
     
    8、textView.delegate = self;  //设置代理方法的实现类
    (其他方法与UITextField用法相同)
     
    四、代理的方法
    1、-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
        //检测每次输入的字符
        return YES;
    }
     
     
  • 相关阅读:
    土豆案例(display:none和block的应用)
    显示和隐藏
    鼠标经过提高层级案例(margin,相对定位,z-index)
    垂直对齐vertical-align
    表单初始化
    使用定位隐式转换为行内块元素
    清除浮动的方法
    定位的盒子叠放顺序z-index
    FreeRTOS-为什么关中断之后切换进程?
    PowerPC-关闭中断后,还能报sc中断?
  • 原文地址:https://www.cnblogs.com/wxzboke/p/4956527.html
Copyright © 2011-2022 走看看