在Xamarin中如何更改iOS7中UITextField占位符的颜色和字体

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

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

}

我正在使用上述代码,但它并没有起作用。

Xamarin编码与xcode-5有何不同? - Pradhyuman sinh
1
你可以使用attributedPlaceholder属性。在这里查看:http://iosapi.xamarin.com/?link=P%3aMonoTouch.UIKit.UITextField.AttributedPlaceholder - Cray
哇,谢谢Cray。简单的解决方案,我差点错过了。你应该把它作为答案! - schmidiii
我的答案可以接受吗? - Jack
1个回答

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 
);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接