经常使用属性解读:字体
@property(nonatomic,assign) id<UITextViewDelegate> delegate;atom
设置代理属性spa
@property(nonatomic,copy) NSString *text;.net
textView上的文本3d
@property(nonatomic,retain) UIFont *font;代理
设置文本字体code
@property(nonatomic,retain) UIColor *textColor;字符串
设置文本颜色get
@property(nonatomic) NSTextAlignment textAlignment; input
设置文本对齐模式
@property(nonatomic) NSRange selectedRange;
设置选中的文本范围(只有当textView是第一响应时才有效)
@property(nonatomic,getter=isEditable) BOOL editable;
设置是否能够编辑
@property(nonatomic,getter=isSelectable) BOOL selectable;
设置是否能够选中
@property(nonatomic) UIDataDetectorTypes dataDetectorTypes;
这个属性能够将本文中的电话,邮件等变为连接,长按会调用响应响应的程序(textView必须为不可编辑状态),属性的枚举以下:
typedef NS_OPTIONS(NSUInteger, UIDataDetectorTypes) { UIDataDetectorTypePhoneNumber = 1 << 0, // 电话变为连接 UIDataDetectorTypeLink = 1 << 1, // 网址变为连接 UIDataDetectorTypeAddress = 1 << 2, // 地址变为连接 UIDataDetectorTypeCalendarEvent = 1 << 3, // 日历变为连接 UIDataDetectorTypeNone = 0, // 无链接 UIDataDetectorTypeAll = NSUIntegerMax // 全部类型连接 };
@property(nonatomic) BOOL allowsEditingTextAttributes;
设置是否容许编辑属性字符串文本
@property(nonatomic,copy) NSAttributedString *attributedText;
设置属性字符串文本
@property(nonatomic,copy) NSDictionary *typingAttributes;
设置属性字符串文本属性字典
- (void)scrollRangeToVisible:(NSRange)range;
滚动textView使其显示在本一段文本
@property (readwrite, retain) UIView *inputView;
设置成为第一响应时弹出的视图,键盘视图
@property (readwrite, retain) UIView *inputAccessoryView;
设置成为第一响应时弹出的副视图,副键盘视图
@property(nonatomic) BOOL clearsOnInsertion;
设置是否显示删除按钮
UITextViewDelegate中的方法
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView;
是否开始编辑
- (BOOL)textViewShouldEndEditing:(UITextView *)textView;
是否结束编辑
- (void)textViewDidBeginEditing:(UITextView *)textView;
开始编辑时触发的方法
- (void)textViewDidEndEditing:(UITextView *)textView;
结束编辑时触发的方法
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
是否容许字符改变
- (void)textViewDidChange:(UITextView *)textView;
字符内容改变触发的方法
- (void)textViewDidChangeSelection:(UITextView *)textView;
选中内容改变触发的方法
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange;
当文本中的URL进行连接时触发的方法
专一技术,热爱生活,交流技术,也作朋友。
——珲少 QQ群:203317592