您的位置:首页 > 产品设计 > UI/UE

iOS UITextView控件方法简介

2016-03-11 00:00 330 查看
摘要: iOS UI基础控件

1.UITextField的初始化

UITextField*field = [[UITextField alloc] initWithFrame:CGRectMake(0,0,100,100)];


2.设置和拿取文本框中的内容

@property(nullable, nonatomic, copy) NSString * text


3.通过NSAttributedString设置和拿取文本框中的内容

@property(nullable, nonatomic, copy) NSAttributedString * attributedText;

4.设置文本框内文字的颜色

@property(nullable, nonatomic, string) UIColor * textColor;

5.设置文本框中的字体大小

@property(nullable, nonatomic, strong) UIFont * font ;

6.设置文本的中文字的对齐方式

@property(nonatomic) NSTextAlignment textAlignment;

7.设置文本框的输入风格是一个枚举

@property(nonatomic) UITextBorderStyle borderStyle;

8.通过字典设置默认字体的属性,这个属性设置后会影响到全部字体的属性

@property(nonatomic ,copy) NSDictionary<NSString*, id> * defaultTextAttributes;

9.设置文本款中默认状态下的字符

@property(nullable, nonatomic, copy) NSString * placeholder;

10.通过NSAttributedString设置文本款默认状态下的字符

@property(nullable, nonatomic, copy) NSAttributedString * attributedPlaceholder;

11.设置是否在编辑时清空文本框中的内容

@property(nonatomic) BOOL clearsOnBeginEditing;

12.设置文字是否适应文本框的宽度

@property(nonatomic) BOOL adjustsFontSizeToFitWidth;

13.设置最小的字体

@prperty(nonatomic) GCFolat minimumFontSize;

14.设置UITextField的代理方法

@property(nullable, nonatomic, weak) id<UITextFieldDelegate> delegate;

15.设置文本款的背景图片,图片会被拉伸

@property(nullable, nonatomic, strong) UIImage * background;

16.设置禁用时文本框的背景图片

@property(nullable, nonatomic, strong) UIImage * disableBackground;

17.设置文本框是否正在编辑,只读属性

@property(nonatomic, readonly, getter=isEditing) BOOL editing;

18.是否允许更改字符属性字典

@property(nonatomic) BOOL allowsEditingTextAttributes;

19.设置属性字典

@property(nullable, nonatomic, copy) NSDictionary<NSString*, id>*typingAttributes;

20.设置清除按钮的样式

@property(nonatomic) UITextFieldViewMode clearbuttonMode;

21.设置文本框左边的视图和视图的样式(一块设置才有效果)

@property(nullable, nonatomic, string) UIView * leftView

@Property(nonatomic) UITextFieldViewMode leftViewMode;

22.设置文本框右边的视图和视图的样式( 是枚举)
@property(nullable, nonatomic, string) UIView * rightView
@Property(nonatomic) UITextFieldViewMode rightViewMode;
23.(??????)通过重写这几个方法可以改变相应视图的位置

24.(????)这两个视图还有疑问,没有使用过

25.设置输入框成为第一响应者时弹出的视图和辅助视图(类似键盘)

@property(nullable, readwrite, strong) UIView * inputView;

@property(nullable, readwrite, strong) UIView * inputAccessoryView;(accessory附件);

26.是否允许再次编辑是可以在内容中间插入内容

@property(nonatmoic) BOOL clerasOnInsertion;

27.注销第一响应(收键盘可以???????)

- (BOOL)endEditing : (BOOL) force;

28.代理方法

@protocol UITextFieldDelegate <NSObject>

@optional

29.开始编辑时候调用的方法

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

30.已经结束时将要调用的方法

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

31.将要结束编辑时调用的方法,YES可以结束编辑,NO不能够结束编辑

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

32.结束编辑时调用的方法

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

33.输入字符是=时候调用的方法

- (BooL) textField : (UITextField*) textField shouldChangeCharactersInRange : (NSRange)range repolacementString : (NSString*) string;

34.点击清除时调用的方法,YES可以清除 NO不可以清除

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

35.点击return时候触发的方法

- (BOOL) textFieldShouldReturn: (UITextField*) textField;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  IOS UI