• UITextField 和 UITextView


    UITextField

    属性:

    1、frame 坐标

    2、borderStyle 边框样式

    3、placeholder 提示文字

    4、keyboardType 键盘样式(数字键盘,字母键盘等)

    5、keyboardAppearance 键盘外观

    6、secureTextEntry 密文输入

    7、clearButtonMode 清除按钮模式

    8、inputView 弹出视图(自定义view之类的)

    9、leftView 左侧视图(还需要设置左视图模式)

    10、leftViewMode 左侧视图模式

    11、rightView 右侧视图

    12、rightViewMode 右侧视图模式

    13、clearsOnBeginEditing 再次编辑是否清空

    14、contentVerticalAlignment 内容纵向对齐方式

    15、contentHorizontalAlignment 内容横向对齐方式

    16、textAlignment 文本横向对齐方式

    17、adjustsFontSizeToFitWidth 文本滚动

    18、minimumFontSize 最小字号

    19、autocapitalizationType 首字母是否大写

    20、returnKeyType return键样式

    1、键盘样式(数字键盘,字母键盘):

    (1)UIKeyboardTypeDefault, // 默认键盘:支持所有字符   

    (2)UIKeyboardTypeASCIICapable, // 支持ASCII的默认键盘   

    (3)UIKeyboardTypeNumbersAndPunctuation, // 标准电话键盘,支持+*#等符号   

    (4)UIKeyboardTypeURL, // URL键盘,有.com按钮;只支持URL字符   

    (5)UIKeyboardTypeNumberPad,           //数字键盘   

    (6)UIKeyboardTypePhonePad,           // 电话键盘   

    (7)UIKeyboardTypeNamePhonePad, // 电话键盘,也支持输入人名字   

    (8)UIKeyboardTypeEmailAddress, // 用于输入电子邮件地址的键盘   

    2、键盘外观

    (1) UIKeyboardAppearanceDefault/UIKeyboardAppearanceLight // 默认外观:浅灰色 ,近白色

    (2)UIKeyboardAppearanceAlert/UIKeyboardAppearanceDark       //深灰/石墨色

    方法:

    (以下几种方法都是需先声明协议<UITextFieldDelegate>,然后复写以下方法)

    1、//文本输入框是否进入编辑模式

    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;

    2、//文本输入框已经进入编辑模式

    - (void)textFieldDidBeginEditing:(UITextField *)textField;

    3、//文本输入框是否可以结束编辑模式

    - (BOOL)textFieldShouldEndEditing:(UITextField *)textField;

    4、//文本输入框已经结束编辑模式

    - (void)textFieldDidEndEditing:(UITextField *)textField;

    5、//文本输入框是否可以点击Clear按钮

    - (BOOL)textFieldShouldClear:(UITextField *)textField;

    6、//文本输入框是否可以点击Return按钮

    - (BOOL)textFieldShouldReturn:(UITextField *)textField

    UITextView

    是文本视图空间,继承自UIScrollView,用于显示或者输入一行或多行文字 

    属性:

    1、text 文字内容

    2、textColor 文字颜色

    3、textAlignment 文字对齐方式

    4、selectedRange 控制滚动

    5、editable 是否可编辑

    方法:

    1、

    - (void)scrollRangeToVisible:(NSRange)range;

    2、

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

    3、

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

    4、

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

    5、

    - (void)textViewDidEndEditing:(UITextView *)textView;

    6、

    //是否可以修改textView

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

    7、

    //改变了textView内容

    -(void)textViewDIdChange:(UITextView *)textView;

    8、

    //开始编辑(包括select all等方法)或修改

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

    自动到textview地步:

    NSUInteger length = textView.text.length;

    textView.selectedRange = NSMaxRange(length,0);

  • 相关阅读:
    C++ malloc 和 new 的函数说明
    C++ const 和static的总结以及使用
    动态库与静态库的区别
    C++引用和指针的区别
    gdb的调试常用命令
    FFMPEG的函数翻译文档
    STL在数组算法的使用
    iOS开发 给Label加下划线、中划线
    更改字符串颜色(长度不确定,有服务器返回)
    iOS 获取键盘高度
  • 原文地址:https://www.cnblogs.com/durwards/p/4525105.html
Copyright © 2020-2023  润新知