繼承 --UITextField
#import "RegisterTextField.m"
//注冊輸入框是通過xib創(chuàng)建,so在此方法初始化
- (void)awakeFromNib
{
// 設置字體
self.font = [UIFont systemFontOfSize:18];
// 設置文字顏色
self.textColor = [UIColor whiteColor];
// 設置光標顏色
self.tintColor = self.textColor;
}
// 在繪圖方法中實現(xiàn)占位文字(顏色鹃祖,大小般此,位置)
- (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];
}
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者