我创建了自定义 TextField 来更改占位符颜色并将文本偏移量向上移动一点。
这里是代码。
-(void)drawPlaceholderInRect:(CGRect)rect{
UIColor *color = [UIColor whiteColor];
self.font = [UIFont fontWithName:@"Gotham-Medium" size:16];
UIFont *font = self.font;
NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
font, NSFontAttributeName,
[NSNumber numberWithFloat:1.0], NSBaselineOffsetAttributeName,color,NSForegroundColorAttributeName, nil];
[[self placeholder] drawInRect:rect withAttributes:attrsDictionary];
}
- (CGRect)textRectForBounds:(CGRect)bounds {
return CGRectInset( bounds , 1 , 5 );
}
// text position
- (CGRect)editingRectForBounds:(CGRect)bounds {
return CGRectInset( bounds , 1 , 5 );
}
- (CGRect)placeholderRectForBounds:(CGRect)bounds{
return CGRectInset( bounds , 1 , 5 );
}
由于自定义 texfield,当在密码字段中键入时,圆点显得很小,返回时 Action 变得正常。
打字时
输入后
最佳答案
From IOS 7 on words apple provided that functionality we can't do any thing and it's not an issue. its by default functionality for secured textfield.
关于ios - 启用安全类型的自定义 TextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24320863/