【发布时间】:2014-06-29 20:30:22
【问题描述】:
所以我一直在尝试更改 UItextfield 占位符的颜色,但我没有运气。我已经尝试过子类化,并且我已经尝试过修改 Attributed 字符串,但没有任何效果,所以希望有人可以帮助我。
这是我累的子类。
public class CustomTextbox : UITextField
{
private string placeholder{ get; set; }
public CustomTextbox ()
{
}
public CustomTextbox(string theString)
{
this.placeholder = theString;
}
public override void DrawPlaceholder (RectangleF rect) {
using (UIFont font = UIFont.SystemFontOfSize (16))
using (UIColor col = new UIColor (UIColor.Blue.CGColor)) {
col.SetFill (); col.SetStroke (); col.SetColor (); base.DrawString (base.Placeholder,rect, font); } }
}
这是我尝试过的属性字符串方法:
var textat = new NSMutableAttributedString ("Email", new CTStringAttributes () {
ForegroundColor = UIColor.White.CGColor,StrokeColor = UIColor.White.CGColor,
StrokeWidth = 5.0f
});
this.emailtextbox.AttributedPlaceholder = textat;
请有人帮助我。提前致谢。
【问题讨论】:
标签: c# ios xamarin.ios uitextfield placeholder