ios中通过调试来使用私有api
转自:http://blog.csdn.net/cubepeng/article/details/11284173
OS不允许使用ios私有api,使用私有api可以获得意想不到的效果 ,同时使用私有api是一个程序员的技术体现之一。至于怎么通过apple的审核,其实是有些办法的,但是不属于今天讨论的范围。私有api可以通过 dump头文件获得,也可以去github clone一份现成的,但是还是推荐自己去dump。但是我们今天不是讨论,如何使用dump到的api,而是通过一个例子来讨论如何通过查看头文件使用 私有api。
我们以UITextfield为例,其实这是个比较简单的控件,有一个蓝色输入的光标,可以在你输入的时候隐藏或者显示,但是并没有给我们提供改变光标颜 色的接口,这个时候我们如果要改变光标的颜色,必然要使用私有api(或者通过比较啰嗦的办法来做这这件事情)。
我们首先需要dump一包头文件,如何class-dump,不是我们今天讨论的要点,现在我们贴上UITextfield的头文件。如果你觉得很长,直接拖到最后面。
- /*
- * Generated by class-dump 3.4 (64 bit).
- *
- * class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2012 by Steve Nygard.
- */
- #import <UIKit/UIControl.h>
- #import "NSCoding.h"
- #import "UIPopoverControllerDelegate.h"
- #import "UITextInput.h"
- @class NSArray, NSAttributedString, NSDictionary, NSString, UIButton, UIColor, UIFont, UIImage, UIImageView, UILabel, UITextFieldAtomBackgroundView, UITextFieldBackgroundView, UITextFieldBorderView, UITextFieldLabel, UITextInputTraits, UITextInteractionAssistant, UITextPosition, UITextRange, UIView, _UIBaselineLayoutStrut, _UITextServiceSession;
- @interface UITextField : UIControl <UIPopoverControllerDelegate, UITextInput, NSCoding>
- {
- NSAttributedString *_text;
- UIColor *_textColor;
- int _borderStyle;
- float _minimumFontSize;
- id _delegate;
- UIImage *_background;
- UIImage *_disabledBackground;
- int _clearButtonMode;
- UIView *_leftView;
- int _leftViewMode;
- UIView *_rightView;
- int _rightViewMode;
- UITextInputTraits *_traits;
- UITextInputTraits *_nonAtomTraits;
- float _fullFontSize;
- float _paddingLeft;
- float _paddingTop;
- float _paddingRight;
- float _paddingBottom;
- NSString *_textFont;
- struct _NSRange _selectionRange;
- int _scrollXOffset;
- int _scrollYOffset;
- float _progress;
- NSString *_style;
- UIButton *_clearButton;
- struct CGSize _clearButtonOffset;
- struct CGSize _leftViewOffset;
- struct CGSize _rightViewOffset;
- UITextFieldBorderView *_backgroundView;
- UITextFieldBorderView *_disabledBackgroundView;
- UITextFieldBackgroundView *_systemBackgroundView;
- UITextFieldLabel *_textLabel;
- UITextFieldLabel *_placeholderLabel;
- UITextFieldLabel *_suffixLabel;
- UITextFieldLabel *_prefixLabel;
- UIImageView *_iconView;
- UILabel *_label;
- float _labelOffset;
- UITextInteractionAssistant *_interactionAssistant;
- UIView *_inputView;
- UIView *_inputAccessoryView;
- UITextFieldAtomBackgroundView *_atomBackgroundView;
- UIColor *_shadowColor;
- struct CGSize _shadowOffset;
- float _shadowBlur;
- struct {
- unsigned int secureTextChanged:1;
- unsigned int guard:1;
- unsigned int delegateRespondsToHandleKeyDown:1;
- unsigned int verticallyCenterText:1;
- unsigned int isAnimating:4;
- unsigned int inactiveHasDimAppearance:1;
- unsigned int becomesFirstResponderOnClearButtonTap:1;
- unsigned int clearsOnBeginEditing:1;
- unsigned int clearsPlaceholderOnBeginEditing:1;
- unsigned int adjustsFontSizeToFitWidth:1;
- unsigned int fieldEditorAttached:1;
- unsigned int canBecomeFirstResponder:1;
- unsigned int shouldSuppressShouldBeginEditing:1;
- unsigned int inResignFirstResponder:1;
- unsigned int undoDisabled:1;
- unsigned int contentsRTL:1;
- unsigned int explicitAlignment:1;
- unsigned int implementsCustomDrawing:1;
- unsigned int needsClearing:1;
- unsigned int suppressContentChangedNotification:1;
- unsigned int allowsEditingTextAttributes:1;
- unsigned int usesAttributedText:1;
- unsigned int backgroundViewState:2;
- unsigned int clearsOnInsertion:1;
- } _textFieldFlags;
- _UITextServiceSession *_definitionSession;
- _UITextServiceSession *_learnSession;
- BOOL _deferringBecomeFirstResponder;
- BOOL _avoidBecomeFirstResponder;
- BOOL _setSelectionRangeAfterFieldEditorIsAttached;
- NSArray *_baselineLayoutConstraints;
- _UIBaselineLayoutStrut *_baselineLayoutLabel;
- }
- @property(retain) UIView *inputView; // @synthesize inputView=_inputView;
- @property(nonatomic) int rightViewMode; // @synthesize rightViewMode=_rightViewMode;
- @property(retain, nonatomic) UIView *rightView; // @synthesize rightView=_rightView;
- @property(nonatomic) int leftViewMode; // @synthesize leftViewMode=_leftViewMode;
- @property(retain, nonatomic) UIView *leftView; // @synthesize leftView=_leftView;
- @property(nonatomic) int clearButtonMode; // @synthesize clearButtonMode=_clearButtonMode;
- @property(retain, nonatomic) UIImage *disabledBackground; // @synthesize disabledBackground=_disabledBackground;
- @property(retain, nonatomic) UIImage *background; // @synthesize background=_background;
- @property(nonatomic) id <UITextFieldDelegate> delegate; // @synthesize delegate=_delegate;
- @property(nonatomic) float minimumFontSize; // @synthesize minimumFontSize=_minimumFontSize;
- @property(nonatomic) int borderStyle; // @synthesize borderStyle=_borderStyle;
- @property(retain, nonatomic, setter=_setBaselineLayoutLabel:) _UIBaselineLayoutStrut *_baselineLayoutLabel; // @synthesize _baselineLayoutLabel;
- @property(copy, nonatomic, setter=_setBaselineLayoutConstraints:) NSArray *_baselineLayoutConstraints; // @synthesize _baselineLayoutConstraints;
- - (void)setSelectionGranularity:(int)arg1;
- - (int)selectionGranularity;
- - (id)_findWebViewWordBoundaryFromPosition:(id)arg1;
- @property(nonatomic) int selectionAffinity;
- - (id)characterRangeAtPoint:(struct CGPoint)arg1;
- - (id)closestPositionToPoint:(struct CGPoint)arg1 withinRange:(id)arg2;
- - (id)closestPositionToPoint:(struct CGPoint)arg1;
- - (struct CGRect)caretRectForPosition:(id)arg1;
- - (struct CGRect)firstRectForRange:(id)arg1;
- - (void)setBaseWritingDirection:(int)arg1 forRange:(id)arg2;
- - (int)baseWritingDirectionForPosition:(id)arg1 inDirection:(int)arg2;
- - (id)characterRangeByExtendingPosition:(id)arg1 inDirection:(int)arg2;
- - (id)positionWithinRange:(id)arg1 farthestInDirection:(int)arg2;
- @property(readonly, nonatomic) id <UITextInputTokenizer> tokenizer;
- @property(nonatomic) id <UITextInputDelegate> inputDelegate;
- - (int)offsetFromPosition:(id)arg1 toPosition:(id)arg2;
- - (int)comparePosition:(id)arg1 toPosition:(id)arg2;
- - (id)positionFromPosition:(id)arg1 inDirection:(int)arg2 offset:(int)arg3;
- - (id)positionFromPosition:(id)arg1 offset:(int)arg2;
- - (id)textRangeFromPosition:(id)arg1 toPosition:(id)arg2;
- @property(readonly, nonatomic) UITextPosition *endOfDocument;
- @property(readonly, nonatomic) UITextPosition *beginningOfDocument;
- - (void)unmarkText;
- - (void)setMarkedText:(id)arg1 selectedRange:(struct _NSRange)arg2;
- @property(copy, nonatomic) NSDictionary *markedTextStyle;
- @property(readonly, nonatomic) UITextRange *markedTextRange;
- @property(copy) UITextRange *selectedTextRange;
- - (void)replaceRange:(id)arg1 withText:(id)arg2;
- - (id)textInRange:(id)arg1;
- - (BOOL)hasText;
- - (id)metadataDictionariesForDictationResults;
- - (struct CGRect)frameForDictationResultPlaceholder:(id)arg1;
- - (void)removeDictationResultPlaceholder:(id)arg1 willInsertResult:(BOOL)arg2;
- - (id)insertDictationResultPlaceholder;
- - (void)insertDictationResult:(id)arg1 withCorrectionIdentifier:(id)arg2;
- - (void)insertText:(id)arg1;
- - (void)deleteBackward;
- - (id)_proxyTextInput;
- - (BOOL)canPerformAction:(SEL)arg1 withSender:(id)arg2;
- - (BOOL)inPopover;
- - (void)_promptForReplace:(id)arg1;
- - (void)replace:(id)arg1;
- - (void)_showTextStyleOptions:(id)arg1;
- - (void)toggleUnderline:(id)arg1;
- - (void)toggleItalics:(id)arg1;
- - (void)toggleBoldface:(id)arg1;
- - (void)makeTextWritingDirectionLeftToRight:(id)arg1;
- - (void)makeTextWritingDirectionRightToLeft:(id)arg1;
- - (void)selectAll:(id)arg1;
- - (void)select:(id)arg1;
- - (void)paste:(id)arg1;
- - (void)_addShortcut:(id)arg1;
- - (void)_selectionMayChange:(id)arg1;
- - (BOOL)_isDisplayingReferenceLibraryViewController;
- - (void)_define:(id)arg1;
- - (void)copy:(id)arg1;
- - (void)cut:(id)arg1;
- - (id)webView;
- - (struct CGPoint)constrainedPoint:(struct CGPoint)arg1;
- - (unsigned int)offsetInMarkedTextForSelection:(id)arg1;
- - (struct CGRect)closestCaretRectInMarkedTextRangeForPoint:(struct CGPoint)arg1;
- - (id)selectedAttributedText;
- - (id)selectedText;
- - (id)selectionRectsForRange:(id)arg1;
- - (struct CGRect)_selectionClipRect;
- - (id)interactionAssistant;
- - (id)selectionView;
- - (void)cancelAutoscroll;
- - (void)startAutoscroll:(struct CGPoint)arg1;
- - (BOOL)hasSelection;
- - (id)_fieldEditor;
- - (void)endSelectionChange;
- - (void)beginSelectionChange;
- - (BOOL)isEditable;
- - (id)undoManager;
- - (int)atomStyle;
- - (void)setAtomStyle:(int)arg1;
- - (BOOL)drawsAsAtom;
- - (void)setDrawsAsAtom:(BOOL)arg1;
- - (void)setClearButtonOffset:(struct CGSize)arg1;
- - (void)_clearButtonClicked:(id)arg1;
- - (BOOL)isUndoEnabled;
- - (void)setUndoEnabled:(BOOL)arg1;
- - (void)setTextCentersVertically:(BOOL)arg1;
- - (void)setTextCentersHorizontally:(BOOL)arg1;
- - (void)setLabel:(id)arg1;
- - (id)textLabel;
- - (void)setLabelOffset:(float)arg1;
- - (BOOL)hasMarkedText;
- - (void)setProgress:(float)arg1;
- - (struct CGRect)iconRect;
- - (void)setBecomesFirstResponderOnClearButtonTap:(BOOL)arg1;
- - (struct CGSize)clearButtonOffset;
- - (void)setIcon:(id)arg1;
- - (unsigned int)characterOffsetAtPoint:(struct CGPoint)arg1;
- - (void)setSelectionRange:(struct _NSRange)arg1;
- - (struct _NSRange)selectionRange;
- - (void)clearText;
- - (void)layoutTilesNow;
- - (void)_resetSelectionUI;
- - (void)_clearSelectionUI;
- - (void)selectAll;
- - (void)setEnabled:(BOOL)arg1;
- - (void)_setEnabled:(BOOL)arg1 animated:(BOOL)arg2;
- - (void)setInactiveHasDimAppearance:(BOOL)arg1;
- - (void)setTextFont:(id)arg1;
- - (float)paddingRight;
- - (void)setPaddingRight:(float)arg1;
- - (float)paddingBottom;
- - (void)setPaddingBottom:(float)arg1;
- - (float)paddingTop;
- - (void)setPaddingTop:(float)arg1;
- - (float)paddingLeft;
- - (void)setPaddingLeft:(float)arg1;
- - (void)setPaddingTop:(float)arg1 paddingLeft:(float)arg2;
- - (void)drawBorder:(struct CGRect)arg1;
- - (void)drawRect:(struct CGRect)arg1;
- - (BOOL)_canDrawContent;
- - (BOOL)_implementsCustomDrawing;
- - (struct CGRect)editRect;
- - (struct CGRect)textRect;
- - (struct CGRect)clearButtonRect;
- - (void)setClearButtonStyle:(int)arg1;
- - (void)setTextAutorresizesToFit:(BOOL)arg1;
- - (void)setAutoresizesTextToFit:(BOOL)arg1;
- - (id)documentFragmentForPasteboardItemAtIndex:(int)arg1;
- - (id)_dictationInterpretations;
- - (id)supportedPasteboardTypesForCurrentSelection;
- - (BOOL)fieldEditor:(id)arg1 shouldReplaceWithText:(id)arg2;
- - (BOOL)fieldEditor:(id)arg1 shouldInsertText:(id)arg2 replacingRange:(struct _NSRange)arg3;
- - (void)fieldEditorDidChangeSelection:(id)arg1;
- - (struct _NSRange)fieldEditor:(id)arg1 willChangeSelectionFromCharacterRange:(struct _NSRange)arg2 toCharacterRange:(struct _NSRange)arg3;
- - (void)selectAllFromFieldEditor:(id)arg1;
- - (void)fieldEditorDidChange:(id)arg1;
- - (id)customOverlayContainer;
- - (void)keyboardInputChangedSelection:(id)arg1;
- - (BOOL)keyboardInputChanged:(id)arg1;
- - (BOOL)keyboardInputShouldDelete:(id)arg1;
- - (BOOL)keyboardInput:(id)arg1 shouldReplaceTextInRange:(struct _NSRange)arg2 replacementText:(id)arg3;
- - (BOOL)keyboardInput:(id)arg1 shouldInsertText:(id)arg2 isMarkedText:(BOOL)arg3;
- - (void)_applicationResuming:(id)arg1;
- - (void)willDetachFieldEditor:(id)arg1;
- - (void)attachFieldEditor:(id)arg1;
- - (void)willAttachFieldEditor:(id)arg1;
- - (void)_drawTextInRect:(struct CGRect)arg1 forLabel:(id)arg2;
- - (void)drawPrefixInRect:(struct CGRect)arg1;
- - (void)drawSuffixInRect:(struct CGRect)arg1;
- - (void)drawPlaceholderInRect:(struct CGRect)arg1;
- - (void)drawTextInRect:(struct CGRect)arg1;
- - (struct CGRect)rightViewRectForBounds:(struct CGRect)arg1;
- - (struct CGRect)leftViewRectForBounds:(struct CGRect)arg1;
- - (struct CGRect)_baselineLeftViewRectForBounds:(struct CGRect)arg1;
- - (struct CGRect)clearButtonRectForBounds:(struct CGRect)arg1;
- - (struct CGRect)editingRectForBounds:(struct CGRect)arg1;
- - (struct CGRect)placeholderRectForBounds:(struct CGRect)arg1;
- - (struct CGRect)textRectForBounds:(struct CGRect)arg1;
- - (struct CGRect)borderRectForBounds:(struct CGRect)arg1;
- @property(retain) UIView *inputAccessoryView;
- @property(readonly, nonatomic, getter=isEditing) BOOL editing;
- - (id)backgroundColor;
- - (void)setBackgroundColor:(id)arg1;
- @property(copy, nonatomic) NSDictionary *typingAttributes;
- @property(nonatomic) BOOL allowsEditingTextAttributes;
- @property(nonatomic) BOOL adjustsFontSizeToFitWidth;
- - (void)setClearsPlaceholderOnBeginEditing:(BOOL)arg1;
- - (BOOL)clearsPlaceholderOnBeginEditing;
- @property(nonatomic) BOOL clearsOnBeginEditing;
- - (void)_setPrefix:(id)arg1;
- - (void)_setSuffix:(id)arg1 withColor:(id)arg2;
- @property(copy, nonatomic) NSAttributedString *attributedPlaceholder;
- @property(copy, nonatomic) NSString *placeholder;
- - (void)createPlaceholderIfNecessary;
- - (void)finishedSettingPlaceholder;
- - (id)createTextLabelWithTextColor:(id)arg1;
- - (void)_createBaselineLayoutLabelIfNecessary;
- - (id)createPlaceholderLabelWithFont:(id)arg1 andTextAlignment:(int)arg2;
- - (void)setContentVerticalAlignment:(int)arg1;
- @property(nonatomic) int textAlignment;
- @property(retain, nonatomic) UIFont *font;
- - (void)disableClearsOnInsertion;
- @property(nonatomic) BOOL clearsOnInsertion;
- - (float)shadowBlur;
- - (void)setShadowBlur:(float)arg1;
- - (struct CGSize)shadowOffset;
- - (void)setShadowOffset:(struct CGSize)arg1;
- - (id)shadowColor;
- - (void)setShadowColor:(id)arg1;
- @property(retain, nonatomic) UIColor *textColor;
- - (void)_updateTextColor;
- @property(copy, nonatomic) NSAttributedString *attributedText;
- - (void)_setAttributedText:(id)arg1 onFieldEditorAndSetCaretSelectionAfterText:(BOOL)arg2;
- - (void)_transferTextFieldPropertiesFromText:(id)arg1;
- - (void)_transferAttribute:(id)arg1 fromString:(id)arg2 andSetPropertyWith:(SEL)arg3 usingValueClass:(Class)arg4;
- @property(copy, nonatomic) NSString *text;
- - (void)finishedSettingTextOrAttributedText;
- - (id)searchText;
- - (BOOL)_hasContent;
- - (id)_attributedText;
- - (id)_text;
- @property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry; // @dynamic secureTextEntry;
- - (void)_updateTextLabel;
- - (BOOL)respondsToSelector:(SEL)arg1;
- - (id)methodSignatureForSelector:(SEL)arg1;
- - (void)forwardInvocation:(id)arg1;
- - (id)textInputTraits;
- - (BOOL)_shouldSendContentChangedNotificationsIfOnlyMarkedTextChanged;
- - (id)_textLabelView;
- - (id)_placeholderLabel;
- - (id)_placeholderView;
- - (id)_placeholderColor;
- - (void)_setSystemBackgroundViewActive:(BOOL)arg1;
- - (BOOL)_fieldEditorAttached;
- - (Class)_systemBackgroundViewClass;
- - (void)_setRightViewOffset:(struct CGSize)arg1;
- - (struct CGSize)_rightViewOffset;
- - (void)_setLeftViewOffset:(struct CGSize)arg1;
- - (struct CGSize)_leftViewOffset;
- - (struct CGPoint)_scrollOffset;
- - (id)actualFont;
- - (float)actualMinimumFontSize;
- - (struct CGRect)adjustedCaretRectForCaretRect:(struct CGRect)arg1;
- - (void)_updateRTLStateForText:(id)arg1 updateAlignment:(BOOL)arg2;
- - (void)_setImplicitAlignment;
- - (void)_clearBackgroundViews;
- - (void)_updateBackgroundViewsAnimated:(BOOL)arg1;
- - (BOOL)_shouldEndEditing;
- - (void)layoutSubviews;
- - (struct CGRect)_prefixFrame;
- - (struct CGRect)_suffixFrame;
- - (void)updateConstraints;
- - (void)_setUpBaselineLayoutConstraints;
- - (struct CGRect)_frameForLabel:(id)arg1 inTextRect:(struct CGRect)arg2;
- - (void)_updateLabel;
- - (struct CGRect)_textRectExcludingButtonsForBounds:(struct CGRect)arg1;
- - (struct CGRect)_textRectForBounds:(struct CGRect)arg1 forEditing:(BOOL)arg2;
- - (BOOL)_isShowingPrefix;
- - (BOOL)_isShowingPlaceholder;
- - (BOOL)_showsRightView;
- - (BOOL)_showsLeftView;
- - (BOOL)_showsClearButtonWhenEmpty;
- - (BOOL)_showsClearButton:(BOOL)arg1;
- - (BOOL)_showsClearButtonWhenNonEmpty:(BOOL)arg1;
- - (void)_updateAtomBackground;
- - (BOOL)_showsAtomBackground;
- - (BOOL)_partsShouldBeMini;
- - (BOOL)_heightShouldBeMini;
- - (struct CGRect)_atomBackgroundViewFrame;
- - (void)_updateAutosizeStyleIfNeeded;
- - (void)_updateButtons;
- - (id)_clearButton;
- - (id)clearButton;
- - (id)_clearButtonImageForState:(unsigned int)arg1;
- - (void)_endedEditing;
- - (id)_style;
- - (id)_createCSSStyleDeclarationForWebView:(id)arg1;
- - (float)_marginTop;
- - (id)_copyFont:(id)arg1 newSize:(float)arg2 maxSize:(float)arg3;
- - (void)setFont:(id)arg1 fullFontSize:(float)arg2;
- - (id)hitTest:(struct CGPoint)arg1 withEvent:(id)arg2;
- - (void)touchesEnded:(id)arg1 withEvent:(id)arg2;
- - (void)touchesCancelled:(id)arg1 withEvent:(id)arg2;
- - (void)_resignFirstResponder;
- - (void)_windowBecameKey;
- - (BOOL)resignFirstResponder;
- - (void)_removeShortcutController;
- - (void)_removeDefinitionController;
- - (void)_becomeFirstResponder;
- - (void)_updatePlaceholderPosition;
- - (int)_currentTextAlignment;
- - (void)__resumeBecomeFirstResponder;
- - (void)_becomeFirstResponderAndMakeVisible;
- - (BOOL)_requiresKeyboardResetOnReload;
- - (id)_keyboardResponder;
- - (BOOL)canResignFirstResponder;
- - (BOOL)canBecomeFirstResponder;
- - (struct CGSize)sizeThatFits:(struct CGSize)arg1;
- - (struct CGSize)_intrinsicSizeWithinSize:(struct CGSize)arg1;
- - (id)viewForBaselineLayout;
- - (struct CGSize)_textSize;
- - (struct CGSize)_textSizeUsingFullFontSize:(BOOL)arg1;
- - (void)setAnimating:(BOOL)arg1;
- - (void)setBounds:(struct CGRect)arg1;
- - (void)setFrame:(struct CGRect)arg1;
- - (void)_sizeChanged:(BOOL)arg1;
- - (void)_setNeedsStyleRecalc;
- - (void)_clearStyle;
- - (void)dealloc;
- - (void)_encodeBackgroundColorWithCoder:(id)arg1;
- - (void)encodeWithCoder:(id)arg1;
- - (void)_populateArchivedSubviews:(id)arg1;
- - (id)initWithCoder:(id)arg1;
- - (id)initWithFrame:(struct CGRect)arg1;
- - (void)_invalidateBaselineLayoutConstraints;
- - (id)_scriptingInfo;
- - (void)decodeRestorableStateWithCoder:(id)arg1;
- - (void)encodeRestorableStateWithCoder:(id)arg1;
- - (BOOL)isElementAccessibilityExposedToInterfaceBuilder;
- - (BOOL)isAccessibilityElementByDefault;
- // Remaining properties
- @property(nonatomic) int autocapitalizationType; // @dynamic autocapitalizationType;
- @property(nonatomic) int autocorrectionType; // @dynamic autocorrectionType;
- @property(nonatomic) BOOL enablesReturnKeyAutomatically; // @dynamic enablesReturnKeyAutomatically;
- @property(nonatomic) int keyboardAppearance; // @dynamic keyboardAppearance;
- @property(nonatomic) int keyboardType; // @dynamic keyboardType;
- @property(nonatomic) int returnKeyType; // @dynamic returnKeyType;
- @property(nonatomic) int spellCheckingType; // @dynamic spellCheckingType;
- @property(readonly, nonatomic) UIView *textInputView;
- @end
首先我们看它声明的方法,关于cursor 的函数,或者表示类似颜色设置的函数,一看之下,没有。这个时候我们注意到有一个函数是 - (id)textInputTraits;
字面意思上是文本输入特征的意思,这个很有可能是我们需要的设置光标的颜色,ok,现在我们开始写代码。
省略创建project的步骤,直接上代码
我们看到private 下面,有一行是标识color的,很可能这个就是我们找的光标样色的属性。同样我们看一下 UITextfieldTraits的头文件,找到我们需要调用的函数。
- /*
- * Generated by class-dump 3.4 (64 bit).
- *
- * class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2012 by Steve Nygard.
- */
- #import "NSObject.h"
- #import "NSCopying.h"
- #import "UITextInputTraits.h"
- #import "UITextInputTraits_Private.h"
- @class UIColor, UIImage;
- @interface UITextInputTraits : NSObject <UITextInputTraits, UITextInputTraits_Private, NSCopying>
- {
- int autocapitalizationType;
- int autocorrectionType;
- int spellCheckingType;
- unsigned int keyboardType:8;
- unsigned int keyboardAppearance:8;
- int returnKeyType;
- BOOL enablesReturnKeyAutomatically;
- BOOL secureTextEntry;
- struct __CFCharacterSet *textTrimmingSet;
- UIColor *insertionPointColor;
- UIColor *selectionBarColor;
- UIColor *selectionHighlightColor;
- UIImage *selectionDragDotImage;
- unsigned int insertionPointWidth;
- int textLoupeVisibility;
- int textSelectionBehavior;
- id textSuggestionDelegate;
- BOOL contentsIsSingleValue;
- BOOL acceptsEmoji;
- BOOL returnKeyGoesToNextResponder;
- BOOL acceptsFloatingKeyboard;
- BOOL acceptsSplitKeyboard;
- BOOL displaySecureTextUsingPlainText;
- BOOL learnsCorrections;
- int emptyContentReturnKeyType;
- int shortcutConversionType;
- BOOL suppressReturnKeyStyling;
- BOOL forceEnableDictation;
- BOOL useInterfaceLanguageForLocalization;
- BOOL deferBecomingResponder;
- }
- + (BOOL)keyboardTypeRequiresASCIICapable:(int)arg1;
- + (id)traitsByAdoptingTraits:(id)arg1;
- + (id)defaultTextInputTraits;
- @property(nonatomic) BOOL deferBecomingResponder; // @synthesize deferBecomingResponder;
- @property(nonatomic) BOOL useInterfaceLanguageForLocalization; // @synthesize useInterfaceLanguageForLocalization;
- @property(nonatomic) BOOL forceEnableDictation; // @synthesize forceEnableDictation;
- @property(nonatomic) BOOL suppressReturnKeyStyling; // @synthesize suppressReturnKeyStyling;
- @property(nonatomic) int shortcutConversionType; // @synthesize shortcutConversionType;
- @property(nonatomic) BOOL learnsCorrections; // @synthesize learnsCorrections;
- @property(nonatomic) BOOL displaySecureTextUsingPlainText; // @synthesize displaySecureTextUsingPlainText;
- @property(nonatomic) BOOL acceptsSplitKeyboard; // @synthesize acceptsSplitKeyboard;
- @property(nonatomic) BOOL acceptsFloatingKeyboard; // @synthesize acceptsFloatingKeyboard;
- @property(nonatomic) BOOL returnKeyGoesToNextResponder; // @synthesize returnKeyGoesToNextResponder;
- @property(nonatomic) int emptyContentReturnKeyType; // @synthesize emptyContentReturnKeyType;
- @property(nonatomic) BOOL acceptsEmoji; // @synthesize acceptsEmoji;
- @property(nonatomic) BOOL contentsIsSingleValue; // @synthesize contentsIsSingleValue;
- @property(nonatomic) int textSelectionBehavior; // @synthesize textSelectionBehavior;
- @property(nonatomic) int textLoupeVisibility; // @synthesize textLoupeVisibility;
- @property(nonatomic) unsigned int insertionPointWidth; // @synthesize insertionPointWidth;
- @property(retain, nonatomic) UIImage *selectionDragDotImage; // @synthesize selectionDragDotImage;
- @property(retain, nonatomic) UIColor *selectionHighlightColor; // @synthesize selectionHighlightColor;
- @property(retain, nonatomic) UIColor *selectionBarColor; // @synthesize selectionBarColor;
- @property(retain, nonatomic) UIColor *insertionPointColor; // @synthesize insertionPointColor;
- @property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry; // @synthesize secureTextEntry;
- @property(nonatomic) BOOL enablesReturnKeyAutomatically; // @synthesize enablesReturnKeyAutomatically;
- @property(nonatomic) int returnKeyType; // @synthesize returnKeyType;
- @property(nonatomic) int keyboardAppearance; // @synthesize keyboardAppearance;
- @property(nonatomic) int keyboardType; // @synthesize keyboardType;
- @property(nonatomic) int spellCheckingType; // @synthesize spellCheckingType;
- @property(nonatomic) int autocorrectionType; // @synthesize autocorrectionType;
- @property(nonatomic) int autocapitalizationType; // @synthesize autocapitalizationType;
- - (BOOL)isEqual:(id)arg1;
- - (id)description;
- - (id)copyWithZone:(struct _NSZone *)arg1;
- - (void)takeTraitsFrom:(id)arg1;
- - (void)setToDefaultValues;
- - (void)dealloc;
- - (id)init;
- @property(nonatomic) id textSuggestionDelegate; // @dynamic textSuggestionDelegate;
- @property(nonatomic) struct __CFCharacterSet *textTrimmingSet; // @dynamic textTrimmingSet;
- - (id)dictionaryRepresentation;
- - (void)setToSecureValues;
- @end
我们找到一个property : insertionPointColor,字面意思上基本上确定这个就是我们要找的设置光标的函数。
经过尝试果然如此,现在贴上结果
各位看官,这次的关于私有api的分析就结束了,其实整个过程没这么顺利,只是我省掉了一些,本身这个做法我也没有用到项目中,而是选择一个开源的 项目,但是对于私有api的熟悉也体现一个程序员对于apple这套东西的熟悉,同时我们可以模仿私有的实现,做一些事情,但是不推荐大家直接使用私有 api。
转载于:https://www.cnblogs.com/frounk/p/4708815.html
ios中通过调试来使用私有api相关推荐
- Audio Unit: iOS中最底层最强大的音频控制API
阅读的前提: Audio Session基础(Audio Session) Core Audio基本数据结构(Core Audio) 音视频基础知识 C/C++ 简单数据结构,函数使用 以下概念是文中 ...
- iOS 中的 timer 任务(寻找内存恶鬼之旅)
前言 在 iOS 的开发过程中定时任务中能找到使用的场景,然而在 iOS 中默认的有关 timer 的 api 总是那么晦涩难用,而且暗坑不断,一旦遇上,会让你一脸懵逼,为了不再同一个地方跌倒两次,我 ...
- iOS私有Api检测
个人原文博客地址: iOS私有Api检测 最近提交APP审核被苹果的审核人员是虐的不要不要的, 一直都说是使用了私有API 但是我使出了浑身解数, 也没找到自己写的代码里哪里用到了私有API, 最后网 ...
- class-dump获取iOS私有api
转自:http://blog.csdn.net/sunyuanyang625/article/details/41440167 获取各类iOS私有api 安装工具class-dump 资源地址http ...
- class-dump导出iOS系统私有库以及简单的私有API调用
前言 This is a command-line utility for examining the Objective-C runtim information stored in Mach-O ...
- iOS私有API检测扫描思路以及工具开发(Python3 + Django)
不足之处 1.class-dump有些文件会报错,由于只支持OC runtime的方式获取,可执行文件是c或者swift都无法被dump 2.私有api在公开的Framework及私有的Private ...
- iOS buttonWithType:101 苹果私有api
无意中发现,有人创建UIButton这样写 UIButton *previousButton = [UIButtonbuttonWithType:101]; 一看原来是私有api UIButton * ...
- 微信开发者工具模拟器、IOS真机调试、Android真机调试中Editor效果不一致问题
问题环境: 1.微信开发者工具1.05.2110290(以下简称"工具") 2.真机调试1.0版本(不区分IOS与Android) 3.微信的editor component,用于 ...
- iOS 中使用 Mobile Installation 安装 IPA(使用iTunes/AppStore一样的安装API)
iOS 中要安装一个程序,从用户角度看有三种: 1. 类似 Cydia 这种 DEB 的方式:直接安装到 /Applications 作为系统的APP,无法长按删除(不讨论CyDelete). 2. ...
最新文章
- jzoj3059-雕塑【容斥,数论】
- HDU6736 F.Forest Program(dfs找环)
- 微信公众号开发之授权获取用户信息
- 混合云架构,如何实现混合云落地?(上)
- VS2010 + OpenCL 1.1 @ Windows 7 + AMD HD6870
- layui按条件开启关闭编辑列
- Java 随机生成MAC地址
- 手动批量下载ts文件并合并
- 502 proxy error解决方法_Homebrew安装、卸载、可能的报错及解决方案_Mac
- 因式分解的常用三种方法
- P1195 口袋的天空
- Java开发 - Redis初体验
- Log日志存放到本地文件
- 一文总结十大经典排序算法(思维导图 + 动图演示 + 代码实现 C/C++/Python + 致命吐槽)
- 淘宝MySQL数据库高可用实现方案
- 【转】Jackson之多态反序列化(父类转不同子类)
- matlab bvp4c猜测解,bvp4c解边界值微分方程
- 山东师大计算机专业研究生,山东师范大学现代教育技术(专硕)专业考研难度分析-专业排名-难度大小...
- PRE_LOAD+putenv
- 金蝶k3服务器老是自动重新启动,金蝶K3:常见问题分析及解决方法
热门文章
- 福布斯2015中国非上市潜力企业100强
- 在ASP.NET MVC中使用IIS级别的URL Rewrite
- djano-cms学习笔计(一)
- IOS网络编程之http请求响应篇
- 计算机桌面文件管理窗口,隐藏Win10此电脑窗口的6个额外文件夹
- git rebase用法
- DPDK rte_mbuf
- leetcode算法题--二叉搜索树迭代器
- 在刷一道题,数字回文,以以前做过,刚好昨天也做了一个类似的题,数字反转,原理有点像-----9. Palindrome Number...
- sonar做代码检测时如何忽略一些代码文件