继承 --UITextField
#import "RegisterTextField.m"
//注册输入框是通过xib创建,so在此方法初始化
- (void)awakeFromNib
{
// 设置字体
self.font = [UIFont systemFontOfSize:18];
// 设置文字颜色
self.textColor = [UIColor whiteColor];
// 设置光标颜色
self.tintColor = self.textColor;
}
// 在绘图方法中实现占位文字(颜色,大小,位置)
- (void)drawPlaceholderInRect:(CGRect)rect
{
// 占位文字的属性
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
attrs[NSFontAttributeName] = self.font;
attrs[NSForegroundColorAttributeName] = self.textColor;
// 画出占位文字
CGPoint point;
point.x = 0;
point.y = (self.frame.size.height - self.font.lineHeight) * 0.5;
[self.placeholder drawAtPoint:point withAttributes:attrs];
}
网友评论