textFiled 知识点

1.placeholder 设置颜色

[self.accountTF setValue:[UIColor blueColor] forKeyPath:@"_placeholderLabel.textColor”];
kvo/kvc考点:
  • KVC key-value-coding键值编码,提供一种机制来讲解的访问对象属性, NSKeyValueCoding。kvo是基于kvc实现的关键技术点之一。
  • 常用方法
- (void)setValue:(nullable id)value forKey:(NSString *)key;
- (BOOL)validateValue:(inout id _Nullable * _Nonnull)ioValue forKey:(NSString *)inKey error:(out NSError **)outError;
- (nullable id)valueForUndefinedKey:(NSString *)key;
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *, id> *)keyedValues;
  • KVO NSKeyValueObserving,是建立在KVC之上,它能够观察一个对象KVC key path的变化,observeValueForKeyPath:ofObject:change:context: 在被观察的 key path 的值变化时调用。
textfiled 有多少隐藏属性
{
unsigned int count = 0;
    Ivar *ivars = class_copyIvarList([UITextField class], &count);
    for (int i = 0; i < count; i++) {
        Ivar ivar = ivars[i];
        NSString *name = [NSString stringWithUTF8String:ivar_getName(ivar)];
        NSString *type = [NSString stringWithUTF8String:ivar_getTypeEncoding(ivar)];
        NSLog(@"属性->%@ 和 type-> %@",name,type);
    }
}
打印结果:
2018-02-27 16:39:56.430681+0800 HJLoginDemo[16686:1152537] 属性->_borderStyle 和 type-> q
2018-02-27 16:39:56.430893+0800 HJLoginDemo[16686:1152537] 属性->_minimumFontSize 和 type-> d
2018-02-27 16:39:56.431123+0800 HJLoginDemo[16686:1152537] 属性->_delegate 和 type-> @
2018-02-27 16:39:56.431619+0800 HJLoginDemo[16686:1152537] 属性->_background 和 type-> @"UIImage"
2018-02-27 16:39:56.431938+0800 HJLoginDemo[16686:1152537] 属性->_disabledBackground 和 type-> @"UIImage"
2018-02-27 16:39:56.432256+0800 HJLoginDemo[16686:1152537] 属性->_clearButtonMode 和 type-> q
2018-02-27 16:39:56.432797+0800 HJLoginDemo[16686:1152537] 属性->_leftView 和 type-> @"UIView"
2018-02-27 16:39:56.433092+0800 HJLoginDemo[16686:1152537] 属性->_leftViewMode 和 type-> q
2018-02-27 16:39:56.433654+0800 HJLoginDemo[16686:1152537] 属性->_rightView 和 type-> @"UIView"
2018-02-27 16:39:56.434588+0800 HJLoginDemo[16686:1152537] 属性->_rightViewMode 和 type-> q
2018-02-27 16:39:56.434985+0800 HJLoginDemo[16686:1152537] 属性->_traits 和 type-> @"UITextInputTraits"
2018-02-27 16:39:56.435254+0800 HJLoginDemo[16686:1152537] 属性->_nonAtomTraits 和 type-> @"UITextInputTraits"
2018-02-27 16:39:56.435502+0800 HJLoginDemo[16686:1152537] 属性->_fullFontSize 和 type-> @"_UIFullFontSize"
2018-02-27 16:39:56.435683+0800 HJLoginDemo[16686:1152537] 属性->_padding 和 type-> {UIEdgeInsets="top"d"left"d"bottom"d"right"d}
2018-02-27 16:39:56.435940+0800 HJLoginDemo[16686:1152537] 属性->_progress 和 type-> f
2018-02-27 16:39:56.436093+0800 HJLoginDemo[16686:1152537] 属性->_clearButton 和 type-> @"UIButton"
2018-02-27 16:39:56.436291+0800 HJLoginDemo[16686:1152537] 属性->_clearButtonOffset 和 type-> {CGSize="width"d"height"d}
2018-02-27 16:39:56.436477+0800 HJLoginDemo[16686:1152537] 属性->_leftViewOffset 和 type-> {CGSize="width"d"height"d}
2018-02-27 16:39:56.436673+0800 HJLoginDemo[16686:1152537] 属性->_rightViewOffset 和 type-> {CGSize="width"d"height"d}
2018-02-27 16:39:56.436878+0800 HJLoginDemo[16686:1152537] 属性->_backgroundView 和 type-> @"UITextFieldBorderView"
2018-02-27 16:39:56.437132+0800 HJLoginDemo[16686:1152537] 属性->_disabledBackgroundView 和 type-> @"UITextFieldBorderView"
2018-02-27 16:39:56.437335+0800 HJLoginDemo[16686:1152537] 属性->_systemBackgroundView 和 type-> @"UITextFieldBackgroundView"
2018-02-27 16:39:56.437553+0800 HJLoginDemo[16686:1152537] 属性->_textContentView 和 type-> @"_UITextFieldContentView"
2018-02-27 16:39:56.437768+0800 HJLoginDemo[16686:1152537] 属性->_floatingContentView 和 type-> @"_UIFloatingContentView"
2018-02-27 16:39:56.437912+0800 HJLoginDemo[16686:1152537] 属性->_contentBackdropView 和 type-> @"UIVisualEffectView"
2018-02-27 16:39:56.438074+0800 HJLoginDemo[16686:1152537] 属性->_fieldEditorBackgroundView 和 type-> @"_UIDetachedFieldEditorBackgroundView"
2018-02-27 16:39:56.438240+0800 HJLoginDemo[16686:1152537] 属性->_fieldEditorEffectView 和 type-> @"UIVisualEffectView"
2018-02-27 16:39:56.438356+0800 HJLoginDemo[16686:1152537] 属性->_placeholderLabel 和 type-> @"UITextFieldLabel"
2018-02-27 16:39:56.438502+0800 HJLoginDemo[16686:1152537] 属性->_suffixLabel 和 type-> @"UITextFieldLabel"
2018-02-27 16:39:56.438642+0800 HJLoginDemo[16686:1152537] 属性->_prefixLabel 和 type-> @"UITextFieldLabel"
2018-02-27 16:39:56.438810+0800 HJLoginDemo[16686:1152537] 属性->_iconView 和 type-> @"UIImageView"
2018-02-27 16:39:56.439311+0800 HJLoginDemo[16686:1152537] 属性->_label 和 type-> @"UILabel"
2018-02-27 16:39:56.439417+0800 HJLoginDemo[16686:1152537] 属性->_labelOffset 和 type-> d
2018-02-27 16:39:56.439530+0800 HJLoginDemo[16686:1152537] 属性->_overriddenPlaceholder 和 type-> @"NSAttributedString"
2018-02-27 16:39:56.439636+0800 HJLoginDemo[16686:1152537] 属性->_overriddenPlaceholderAlignment 和 type-> q
2018-02-27 16:39:56.439754+0800 HJLoginDemo[16686:1152537] 属性->_interactionAssistant 和 type-> @"UITextInteractionAssistant"
2018-02-27 16:39:56.439953+0800 HJLoginDemo[16686:1152537] 属性->_selectGestureRecognizer 和 type-> @"UITapGestureRecognizer"
2018-02-27 16:39:56.440167+0800 HJLoginDemo[16686:1152537] 属性->_fieldEditor 和 type-> @"UIFieldEditor"
2018-02-27 16:39:56.440368+0800 HJLoginDemo[16686:1152537] 属性->__textContainer 和 type-> @"NSTextContainer"
2018-02-27 16:39:56.440697+0800 HJLoginDemo[16686:1152537] 属性->__layoutManager 和 type-> @"_UIFieldEditorLayoutManager"
2018-02-27 16:39:56.440944+0800 HJLoginDemo[16686:1152537] 属性->_textStorage 和 type-> @"_UICascadingTextStorage"
2018-02-27 16:39:56.441130+0800 HJLoginDemo[16686:1152537] 属性->_pasteController 和 type-> @"UITextPasteController"
2018-02-27 16:39:56.441362+0800 HJLoginDemo[16686:1152537] 属性->_inputView 和 type-> @"UIView"
2018-02-27 16:39:56.441651+0800 HJLoginDemo[16686:1152537] 属性->_inputAccessoryView 和 type-> @"UIView"
2018-02-27 16:39:56.441813+0800 HJLoginDemo[16686:1152537] 属性->_recentsAccessoryView 和 type-> @"UIView"
2018-02-27 16:39:56.442023+0800 HJLoginDemo[16686:1152537] 属性->_systemInputViewController 和 type-> @"UISystemInputViewController"
2018-02-27 16:39:56.442242+0800 HJLoginDemo[16686:1152537] 属性->_atomBackgroundView 和 type-> @"UITextFieldAtomBackgroundView"
2018-02-27 16:39:56.442475+0800 HJLoginDemo[16686:1152537] 属性->_textDragDropSupport 和 type-> @"<UITextDragDropSupport>"
2018-02-27 16:39:56.442671+0800 HJLoginDemo[16686:1152537] 属性->_textFieldFlags 和 type-> {?="verticallyCenterText"b1"isAnimating"b4"inactiveHasDimAppearance"b1"becomesFirstResponderOnClearButtonTap"b1"clearsPlaceholderOnBeginEditing"b1"adjustsFontSizeToFitWidth"b1"fieldEditorAttached"b1"canBecomeFirstResponder"b1"shouldSuppressShouldBeginEditing"b1"inResignFirstResponder"b1"undoDisabled"b1"explicitAlignment"b1"implementsCustomDrawing"b1"needsClearing"b1"suppressContentChangedNotification"b1"allowsEditingTextAttributes"b1"usesAttributedText"b1"backgroundViewState"b2"clearingBehavior"b2"overridePasscodeStyle"b1"shouldResignWithoutUpdate"b1"blurEnabled"b1"disableFocus"b1"disableRemoteTextEditing"b1"allowsAttachments"b1}
2018-02-27 16:39:56.442916+0800 HJLoginDemo[16686:1152537] 属性->_deferringBecomeFirstResponder 和 type-> B
2018-02-27 16:39:56.443121+0800 HJLoginDemo[16686:1152537] 属性->_animateNextHighlightChange 和 type-> B
2018-02-27 16:39:56.443366+0800 HJLoginDemo[16686:1152537] 属性->_cuiCatalog 和 type-> @"CUICatalog"
2018-02-27 16:39:56.443610+0800 HJLoginDemo[16686:1152537] 属性->_cuiStyleEffectConfiguration 和 type-> @"CUIStyleEffectConfiguration"
2018-02-27 16:39:56.443806+0800 HJLoginDemo[16686:1152537] 属性->_roundedRectBackgroundCornerRadius 和 type-> d
2018-02-27 16:39:56.443994+0800 HJLoginDemo[16686:1152537] 属性->_overriddenAttributesForEditing 和 type-> @"NSArray"
2018-02-27 16:39:56.444268+0800 HJLoginDemo[16686:1152537] 属性->_adjustsFontForContentSizeCategory 和 type-> B
2018-02-27 16:39:56.444503+0800 HJLoginDemo[16686:1152537] 属性->_tvUseVibrancy 和 type-> B
2018-02-27 16:39:56.444679+0800 HJLoginDemo[16686:1152537] 属性->_disableTextColorUpdateOnTraitCollectionChange 和 type-> B
2018-02-27 16:39:56.444928+0800 HJLoginDemo[16686:1152537] 属性->_pasteDelegate 和 type-> @"<UITextPasteDelegate>"
2018-02-27 16:39:56.445118+0800 HJLoginDemo[16686:1152537] 属性->_baselineLayoutConstraint 和 type-> @"NSLayoutConstraint"
2018-02-27 16:39:56.445348+0800 HJLoginDemo[16686:1152537] 属性->_baselineLayoutLabel 和 type-> @"_UIBaselineLayoutStrut"
2018-02-27 16:39:56.445570+0800 HJLoginDemo[16686:1152537] 属性->_tvCustomTextColor 和 type-> @"UIColor"
2018-02-27 16:39:56.445812+0800 HJLoginDemo[16686:1152537] 属性->_tvCustomFocusedTextColor 和 type-> @"UIColor"
2018-02-27 16:39:56.446020+0800 HJLoginDemo[16686:1152537] 属性->_textDragOptions 和 type-> q
2018-02-27 16:39:56.446291+0800 HJLoginDemo[16686:1152537] 属性->_textDragDelegate 和 type-> @"<UITextDragDelegate>"
2018-02-27 16:39:56.446466+0800 HJLoginDemo[16686:1152537] 属性->_textDropDelegate 和 type-> @"<UITextDropDelegate>"
2018-02-27 16:39:56.446752+0800 HJLoginDemo[16686:1152537] 属性->_visualStyle 和 type-> @"_UITextFieldVisualStyle"

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,716评论 4 364
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,558评论 1 294
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 109,431评论 0 244
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,127评论 0 209
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,511评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,692评论 1 222
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,915评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,664评论 0 202
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,412评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,616评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,105评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,424评论 2 254
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,098评论 3 238
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,096评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,869评论 0 197
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,748评论 2 276
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,641评论 2 271

推荐阅读更多精彩内容

  • *面试心声:其实这些题本人都没怎么背,但是在上海 两周半 面了大约10家 收到差不多3个offer,总结起来就是把...
    Dove_iOS阅读 27,036评论 29 470
  • KVC(Key-value coding)键值编码,单看这个名字可能不太好理解。其实翻译一下就很简单了,就是指iO...
    朽木自雕也阅读 1,404评论 6 1
  • 本文由我们团队的 纠结伦 童鞋撰写。 文章结构如下: Why? (为什么要用KVO) What? (KVO是什么...
    知识小集阅读 7,382评论 7 105
  • ios中的 kvc和kvo的区别 KVC编程时setValue(value: AnyObje...
    summerTa阅读 142评论 0 0
  • ta会大哭大闹,大喊大叫,你扯着嗓子对ta怒吼,命令ta停止哭泣,但ta只是哭得越来越凶……你狠ta不争气,你骂t...
    不敢言阅读 206评论 2 1