更改占位符颜色
Change placeholder colour
我使用此代码更改了我的占位符颜色,但它不起作用。
我在分类中使用了这个方法
-(void) drawPlaceholderInRect:(CGRect)rect {
[[UIColor blueColor] setFill];
[[self placeholder] drawInRect:rect withFont:[UIFont systemFontOfSize:16]];
}
error:
Category is implementing a method which will also be implemented by its :
'drawInRect:withFont:' 已弃用:首先在 iOS 7.0 中弃用 - 使用 -drawInRect:withAttributes:
尝试:
[[self placeholder] drawInRect:rect
withAttributes:@{
NSFontAttributeName: [UIFont systemFontOfSize:16],
NSBackgroundColorAttributeName: [UIColor blueColor],
NSForegroundColorAttributeName: [UIColor greenColor], //Font Color
}];
而不是'drawInRect:withFont:'
*Attributes 是一个带有你想要的属性的 NSDictionary,你可以在其中指定你想要的字体,以及其他东西,比如颜色等。
我使用此代码更改了我的占位符颜色,但它不起作用。
我在分类中使用了这个方法
-(void) drawPlaceholderInRect:(CGRect)rect {
[[UIColor blueColor] setFill];
[[self placeholder] drawInRect:rect withFont:[UIFont systemFontOfSize:16]];
}
error:
Category is implementing a method which will also be implemented by its :
'drawInRect:withFont:' 已弃用:首先在 iOS 7.0 中弃用 - 使用 -drawInRect:withAttributes:
尝试:
[[self placeholder] drawInRect:rect
withAttributes:@{
NSFontAttributeName: [UIFont systemFontOfSize:16],
NSBackgroundColorAttributeName: [UIColor blueColor],
NSForegroundColorAttributeName: [UIColor greenColor], //Font Color
}];
而不是'drawInRect:withFont:'
*Attributes 是一个带有你想要的属性的 NSDictionary,你可以在其中指定你想要的字体,以及其他东西,比如颜色等。