如何在Xamarin for iOS7中更改UITextField Placeholder的颜色和字体

时间:2013-11-15 10:24:12

标签: ios7 xamarin

using(UIFont font=StyleHelper.Fonts.HelveticaNeueLTDMC_18
using(UIColor color=UIColor.Clear.FromHex(0xc7c7c7))
{
    color.SetFill ();

    base.DrawString (this.Placeholder, rect, font);

}

我正在使用上面的代码,但它无效。

1 个答案:

答案 0 :(得分:9)

MonoTouch.UIKit.UITextField.AttributedPlaceholder的iOS-API文档所示,您可以清楚地看到:

myLogin.AttributedPlaceholder = new NSAttributedString (
    "Enter your credentials",
    font: UIFont.FromName ("HoeflerText-Regular", 24.0f),
    foregroundColor: UIColor.Red,
    strokeWidth: 4 
);