UITextView變量
@property(null_resettable,nonatomic,copy) NSString *text;
// 顯示的文本
@property(nullable,nonatomic,strong) UIFont *font;
// 設(shè)置字體
@property(nullable,nonatomic,strong) UIColor *textColor;
// 設(shè)置字體顏色
@property(nonatomic) NSTextAlignment textAlignment; // default is NSLeftTextAlignment
// 顯示文本的對(duì)齊方式
@property(nonatomic) NSRange selectedRange;
// 可編輯選擇的范圍
@property(nonatomic,getter=isEditable) BOOL editable __TVOS_PROHIBITED;
// 是否可以編輯
@property(nonatomic,getter=isSelectable) BOOL selectable NS_AVAILABLE_IOS(7_0); // toggle selectability, which controls the ability of the user to select content and interact with URLs & attachments
// 是否可以選擇
@property(nonatomic) UIDataDetectorTypes dataDetectorTypes NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED;
// 可識(shí)別文本類型, 如 電話, 網(wǎng)址, 住址, 郵箱等, 相應(yīng)的設(shè)置后, 若點(diǎn)擊則可跳轉(zhuǎn)相應(yīng)的操作
// 源文檔
Discussion
You can use this property to specify the types of data (phone numbers, http links, and so on) that should be automatically converted to URLs in the text view. When tapped, the text view opens the application responsible for handling the URL type and passes it the URL.
Availability
Available in iOS 3.0 and later.
@property(nonatomic) BOOL allowsEditingTextAttributes NS_AVAILABLE_IOS(6_0); // defaults to NO
// 是否允許編輯Attributes的文本.
@property(null_resettable,copy) NSAttributedString *attributedText NS_AVAILABLE_IOS(6_0);
// 富文本的文字;
@property(nonatomic,copy) NSDictionary<NSString *, id> *typingAttributes NS_AVAILABLE_IOS(6_0); // automatically resets when the selection changes
// 全部文本所表示的一個(gè)樣式
源文檔.
Discussion
This dictionary contains the attribute keys (and corresponding values) to apply to newly typed text. When the text view’s selection changes, the contents of the dictionary are cleared automatically.
Availability
Available in iOS 6.0 and later.
@property(nonatomic) BOOL clearsOnInsertion NS_AVAILABLE_IOS(6_0); // defaults to NO. if YES, the selection UI is hidden, and inserting text will replace the contents of the field. changing the selection will automatically set this to NO.
// 設(shè)置textView獲得焦點(diǎn),在用戶使用虛擬鍵盤進(jìn)行輸入時(shí)划栓,清除之前的文本
原文檔
@property(nonatomic, copy) NSDictionary <NSString *,id> *linkTextAttributes The attributes to apply to links.
// 支持連接的樣式.
// 源文檔
Discussion
The default attributes specify blue text with a single underline and the pointing hand cursor.
Availability
Available in iOS 7.0 and later.
@property (nullable, readwrite, strong) UIView *inputView;
// 當(dāng)textView變?yōu)榈谝豁憫?yīng)的時(shí)候, 從底部彈出的視圖, 不設(shè)置時(shí), 默認(rèn)是鍵盤.
@property (nullable, readwrite, strong) UIView *inputAccessoryView;
// 位于inputView上方的視圖, 例如: 可以做個(gè)按鈕, 顯示在鍵盤的上邊, 以用于回收鍵盤.
@property(nonatomic) BOOL clearsOnInsertion NS_AVAILABLE_IOS(6_0); // defaults to NO. if YES, the selection UI is hidden, and inserting text will replace the contents of the field. changing the selection will automatically set this to NO.
// 設(shè)置textView獲得焦點(diǎn)蘑辑,在用戶使用虛擬鍵盤進(jìn)行輸入時(shí),清除之前的文本
@property(nonatomic, assign) UIEdgeInsets textContainerInset NS_AVAILABLE_IOS(7_0);
// 顯示文本的區(qū)域. 默認(rèn)是 (8, 0, 8, 0).
UITextView方法
- (void)scrollRangeToVisible:(NSRange)range;
// 滾動(dòng)到指定 range
UITextViewDelegate 方法
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView;
// 是否應(yīng)該開始編輯
- (void)textViewDidBeginEditing:(UITextView *)textView;
// 已經(jīng)開始編輯
- (void)textViewDidEndEditing:(UITextView *)textView;
// 結(jié)束編輯
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
// 文本改變是否顯示
- (void)textViewDidChange:(UITextView *)textView;
// 文本已經(jīng)改變
- (void)textViewDidChangeSelection:(UITextView *)textView;
//
通知
UIKIT_EXTERN NSString * const UITextViewTextDidBeginEditingNotification;
UIKIT_EXTERN NSString * const UITextViewTextDidChangeNotification;
UIKIT_EXTERN NSString * const UITextViewTextDidEndEditingNotification;
@property(nonatomic,readonly) NSTextContainer *textContainer NS_AVAILABLE_IOS(7_0);
// The text container object defining the area in which text is displayed in this text view. (read-only)
@property(nonatomic,readonly) NSLayoutManager *layoutManager NS_AVAILABLE_IOS(7_0);
// The layout manager that lays out text for the receiver’s text container. (read-only)
@property(nonatomic,readonly,strong) NSTextStorage *textStorage NS_AVAILABLE_IOS(7_0);
// The text storage object holding the text displayed in this text view. (read-only)