UITextField修改place
来源:互联网 发布:北京市工商局网络登记 编辑:程序博客网 时间:2024/05/28 15:20
#import "GYLLoginRegisterTextField.h"@implementation GYLLoginRegisterTextField- (void)awakeFromNib{ self.tintColor = [UIColor whiteColor]; //设置光标颜色}- (void)drawPlaceholderInRect:(CGRect)rect{ NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; attrs[NSForegroundColorAttributeName] = [UIColor whiteColor]; attrs[NSFontAttributeName] = self.font; //画出占位符 CGRect placeholderRect; placeholderRect.size.width = rect.size.width; placeholderRect.size.height = rect.size.height; placeholderRect.origin.x = 0; placeholderRect.origin.y = (rect.size.height - self.font.lineHeight) * 0.5; [self.placeholder drawInRect:placeholderRect withAttributes:attrs]; //或者 /* CGPoint placeholderPoint = CGPointMake(0, (rect.size.height - self.font.lineHeight) * 0.5); [self.placeholder drawAtPoint:placeholderPoint withAttributes:attrs]; */}@end
阅读全文