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 *)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-> @""
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-> @""
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-> @""
2018-02-27 16:39:56.446466+0800 HJLoginDemo[16686:1152537] 属性->_textDropDelegate 和 type-> @""
2018-02-27 16:39:56.446752+0800 HJLoginDemo[16686:1152537] 属性->_visualStyle 和 type-> @"_UITextFieldVisualStyle"