2013-11-15 63 views
4
using(UIFont font=StyleHelper.Fonts.HelveticaNeueLTDMC_18 
using(UIColor color=UIColor.Clear.FromHex(0xc7c7c7)) 
{ 
    color.SetFill(); 

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

} 

我正在使用上面的代碼,但它不起作用。如何更改Xamarin for iOS7中的UITextField佔位符的顏色和字體

+0

Xamarin編碼比的Xcode-5有什麼不同? –

+1

您可以使用attributedPlaceholder屬性。 看看這裏:http://iosapi.xamarin.com/?link=P%3aMonoTouch.UIKit.UITextField.AttributedPlaceholder – Cray

+0

謝謝克雷。我幾乎錯過了簡單的解決方案。你應該讓它成爲答案! – schmidiii

回答

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 
); 
相關問題