继承 --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];
}
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。