IOS-UITextField类
文字屬性
- ??text??
- ??placeholder? //默認使用70%灰色
- ? font?
- ? textColor?
- ? textAlignment?
文字大小
- ??adjustsFontSizeToFitWidth?
- ??minimumFontSize?
編輯行為
- ??editing? //是否正在編輯(read-only)
- ??clearsOnBeginEditing?
展現形態
- ??borderStyle? //默認UITextBorderStyleNone,是UITextBorderStyleRoundedRect時自定義的background無效
- ??background?
- ??disabledBackground??property //background未設置時,這個會無效
覆蓋視圖
- ??clearButtonMode?
- ??leftView? //像clearButton那樣的視圖,不過在左邊,不要忘了設置mode
- ??leftViewMode?
- ??rightView? //默認覆蓋clearButton
- ??rightViewMode?
訪問代理
- ??delegate??property
繪畫界面
以下都不應直接調用,需要的話可以重寫
- –?textRectForBounds: //重寫來重置文字區域
- –?drawTextInRect: //改變繪文字屬性.重寫時調用super可以按默認圖形屬性繪制,若自己完全重寫繪制函數,就不用調用super了.
- –?placeholderRectForBounds: //重寫來重置占位符區域
- –?drawPlaceholderInRect: //重寫改變繪制占位符屬性.重寫時調用super可以按默認圖形屬性繪制,若自己完全重寫繪制函數,就不用調用super了.
- –?borderRectForBounds: //重寫來重置邊緣區域
- –?editingRectForBounds: //重寫來重置編輯區域
- –?clearButtonRectForBounds: //重寫來重置clearButton位置,改變size可能導致button的圖片失真
- –?leftViewRectForBounds:
- –?rightViewRectForBounds:
代替輸入
- ??inputView? //代替標準的系統鍵盤
- ??inputAccessoryView? //編輯時顯示在系統鍵盤或用戶自定義的inputView上面的視圖
?
?
UITextFieldBorderStyle
typedef enum {UITextBorderStyleNone,//無框
UITextBorderStyleLine,//線框
UITextBorderStyleBezel,//bezel風格線框
UITextBorderStyleRoundedRect//圓角邊框
} UITextBorderStyle;
UITextFieldViewMode
typedef enum {UITextFieldViewModeNever,
UITextFieldViewModeWhileEditing,
UITextFieldViewModeUnlessEditing,
UITextFieldViewModeAlways
} UITextFieldViewMode;?
Notifications
UITextFieldTextDidBeginEditingNotification
UITextFieldTextDidChangeNotification
UITextFieldTextDidEndEditingNotification
?
委托事件
@protocol?UITextFieldDelegate?<NSObject>
@optional
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;? ? ? ? //?返回NO則不許編輯
- (void)textFieldDidBeginEditing:(UITextField *)textField; ? ? ? ? ? // became first responder
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField;? ? ? ? ? //?返回YES允許結束并且resign first responder status.?返回NO不許編輯狀態結束
- (void)textFieldDidEndEditing:(UITextField *)textField; ? ? ? ? ? ? //?上面返回YES后執行;上面返回NO時有可能強制執行(e.g. view removed fromwindow)
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string; ? //?返回NO不改變
- (BOOL)textFieldShouldClear:(UITextField *)textField; ? ? ? ? ? ? ? // clear button事件,返回NO過濾之
- (BOOL)textFieldShouldReturn:(UITextField *)textField;? ? ? ? ? ? ? // 'return' key事件.返回NO過濾之
@end
?
轉載于:https://www.cnblogs.com/ubersexual/p/3510916.html
總結
以上是生活随笔為你收集整理的IOS-UITextField类的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jQ零碎01
- 下一篇: leetcode 1038. 从二叉搜索