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。
ios中通过调试来使用私有api的更多相关文章
- iOS中崩溃调试的使用和技巧总结 韩俊强的博客
每日更新关注:http://weibo.com/hanjunqiang 新浪微博 在iOS开发调试过程中以及上线之后,程序经常会出现崩溃的问题.简单的崩溃还好说,复杂的崩溃就需要我们通过解析Cras ...
- iOS私有api检测工具使用
背景:这两天提审了一款新的APP,由于项目中使用了老版本的TZImagePicker中访问了私有API,导致提审失败. 预审经验分享: https://baijiahao.baidu.com/s?id ...
- 软件測试、ios中的測试概念以及步骤
软件測试: 软件測试的目标是应该服务于软件项目的目标,能够通过建议反馈使用更加高效的方法和工具,提升软件开发效率以及软件开发质量.同一时候还能够通过过一些手段,更早.更快.很多其它地发现缺陷.从容减少 ...
- class-dump获取iOS私有api
转自:http://blog.csdn.net/sunyuanyang625/article/details/41440167 获取各类iOS私有api 安装工具class-dump 资源地址http ...
- (iOS)私有API的使用(原创)
最近在做企业级程序,需要搞设备的udid等信息,但是ios7把udid私有化了,不公开使用.所以研究了一下ios的私有api. 调查了一下文章,发现这方面的文章不多,国内更是不全,高手们都懒得写基础教 ...
- iOS 私有API调用
最近自己在做一个小程序,想实现一个一键设置手机壁纸的功能.但在iOS公开的API里找不到相关的方法,只能从私有API入手. 网上有不少教程,不过都不是很详细.从google和https://stack ...
- IOS私有API的使用(转)
最近在做企业级程序,需要搞设备的udid等信息,但是ios7把udid私有化了,不公开使用.所以研究了一下ios的私有api. 调查了一下文章,发现这方面的文章不多,国内更是不全,高手们都懒得写基 ...
- iOS - APP审核Guideline 2.5.1被拒,使用了私有API
最近iOS 审核被拒,说是使用了私有API:com.apple.springboard.lockcomplete 具体内容如下: 发件人 Apple . Performance: Software R ...
- Unity在Android和iOS中如何调用Native API
本文主要是对unity中如何在Android和iOS中调用Native API进行介绍. 首先unity支持在C#中调用C++ dll,这样可以在Android和iOS中提供C++接口在unity中调 ...
随机推荐
- C# 读写App.config
Jul142013 [C#] 读写App.config配置文件的方法 作者:xieyc 发布:2013-07-14 17:29 字符数:3433 分类:编程 阅读: 39,139 次 ...
- JSP自定义标签之Hello Costom tag小例子
1.项目结构 2.实现自定义tag所需依赖 <dependency> <groupId>javax.servlet</groupId> <artifactId ...
- ajax读取XML文本(如读取城市)
//加载城市 function loadArea_pep() { $.ajax({ url: "/xmlFile/crty.xml", success: function (res ...
- 【亲述】Uber容错设计与多机房容灾方案 - 高可用架构系列
此文是根据赵磊在[QCON高可用架构群]中的分享内容整理而成.转载请事先联系赵磊及相关编辑. 赵磊,Uber高级工程师,08年上海交通大学毕业,曾就职于微软,后加入Facebook主要负责Messen ...
- CSU 1113 Updating a Dictionary(map容器应用)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1113 解题报告:输入两个字符串,第一个是原来的字典,第二个是新字典,字典中的元素的格式为 ...
- 阻止点击<a>标签链接跳转
我们常用的在a标签中有点击事件(<a href="地址">链接</a>),其中“href”参数只要不为空,点击该链接时,页面会自动跳转:如果指定的“hr ...
- Caffe学习系列(11):数据可视化环境(python接口)配置
参考:http://www.cnblogs.com/denny402/p/5088399.html 这节配置python接口遇到了不少坑. 1.我是利用anaconda来配置python环境,在将ca ...
- ubuntu: NO_PUBKEY 8D5A09DC9B929006
最近使用ubuntu16.04时,运行 sudo apt-get update 时出现如下错误: W: GPG error: http://archive.ubuntukylin.com:10006/ ...
- 百度网盘爬虫Python
": for i in range((shares["total_count"]-1)/ONESHAREPAGE): try: dbcurr.execute('INSER ...
- BZOJ 3111: [Zjoi2013]蚂蚁寻路
Sol DP. 首先观察转折,画画图,看看移动路线,可以非常轻易的发现如果走到起点的下方是回不去的.. 然后它就相当于一个底部是平的,顶部凹凹凸凸的形状,每右转两次或左转两次就会形成小矩阵,这样就可以 ...