oc swift 重写光标点 高度 宽度 长度
2022-05-09 本文已影响0人
奔跑吧小蚂蚁
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;
}