1. TextView/TextField光标颜色可通过设置tintColor属性进行修改:
self.textView.tintColor = [UIColor redColor];
2. TextView/TextField自定义光标长度或高度, 可通过重写父类方法caretRectForPosition:实现, 具体设置如下:
@interface CustomTextView : UITextView
重写父类方法:
- (CGRect)caretRectForPosition:(UITextPosition *)position { CGRect originalRect = [super caretRectForPosition:position]; originalRect.size.height = self.font.lineHeight + 2; originalRect.size.width = 5; return originalRect; }