Although this question has already been answered, there are some awesome (read private) UITextInputTraits methods (tested on iOS5 and 6b :) I assume that people reading this do not target the AppStore: p
Some of them:
UITextInputTraits *inputTraits = [_textView textInputTraits]; UIColor *purpleColor = [UIColor purpleColor]; [inputTraits setInsertionPointColor:purpleColor]; [inputTraits setInsertionPointWidth:1];
insertionPointWidth: seems to have no effect. You need to override caretRectForPosition: (protocol method UITextInput ) in a subclass of UITextView .
Result:

They are also interesting:
[inputTraits setAcceptsFloatingKeyboard:NO]; [inputTraits setAcceptsSplitKeyboard:NO];
Use these last two, because other text views / fields may accept floating or split keyboards, and the keyboard may not update correctly when your text with custom input features becomes the first responder.
To get a complete list of methods:
- (void)printMethodsOfClass:(Class)class { unsigned int methodCount = 0; NSLog(@"%@", NSStringFromClass(class)); Method *mlist = class_copyMethodList(class, &methodCount); for (int i = 0; i < methodCount; ++i){ NSLog(@"%@", NSStringFromSelector(method_getName(mlist[i]))); } NSLog(@"------------------------------------------------------------"); free(mlist); } [self printMethodsOfClass:[[textview textInputTraits] class]];
nacho4d
source share