iOS placeholder的属性文字 那看到的

一.直接设置textFiled的placeholder的属性文字

NSMutableDictionary *dict = [NSMutableDictionary dictionary];

dict[NSForegroundColorAttributeName] = [UIColor whiteColor];

dict[NSFontAttributeName] = textFiled.font;

textFiled.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@“占位文字”attributes:dict];

二.画出属性文字

-(void)drawPlaceholderInRect:(CGRect)rect{

NSMutableDictionary *dict = [NSMutableDictionary dictionary];

dict[NSForegroundColorAttributeName] = [UIColor whiteColor];

dict[NSFontAttributeName] = textFiled.font;

//设置self.placeholder的位置

CGFloat placeholderW = rect.size.width;

CGFloat placeholderH = textFiled.font.lineHeight;

CGFloat placeholderX = 0;

CGFloat placeholderY = (rect.size.height - placeholderH)*0.5;

[textFiled.placeholder drawInRect:CGRectMake(placeholderX, placeholderY, placeholderW, placeholderH) withAttributes:dict];

}

三.取出系统自带的label设置

UILabel *placeholderLabel = [textFiled valueForKey:@"placeholderLabel"];

placeholderLabel.textColor = [UIColor yellowColor];

[textFiled setValue:[UIColor yellowColor] forKeyPath:@"placeholderLabel.textColor"];

2.设置光标的颜色

一.通过xib或者storyboard设置Tint属性的颜色

二. textFiled.tintColor = [UIColor whiteColor];

你可能感兴趣的:(iOS placeholder的属性文字 那看到的)