swift
// MARK: - 重写UITextField 修改光标宽度
class PlaceholderUITextField: UITextField {
override func caretRect(for position: UITextPosition) -> CGRect {
var rect = super.caretRect(for: position)
rect.size.width = 2
return rect
}
}
OC
- (CGRect)caretRectForPosition:(UITextPosition *)position
{
CGRect originalRect = [super caretRectForPosition:position];
originalRect.size.width = 2;
return originalRect;
}
网友评论