iOS UITextView控件方法简介

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;











转载于:https://my.oschina.net/u/2613084/blog/636113

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值