gpt4 book ai didi

c# - Xamarin iOS 在点击时隐藏占位符

转载 作者:太空宇宙 更新时间:2023-11-03 21:18:32 25 4
gpt4 key购买 nike

我有一个 Xamarin iOS 应用程序,它有文本字段,所以我希望我的文本字段在单击时隐藏它们的占位符,而不仅仅是在我开始输入字母时,这可能吗?

最佳答案

类似下面的内容:

  string _placeHolderText = "Some Test Placeholder...";

public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);

var textView1 = new UITextField (new CGRect (0, 0, UIScreen.MainScreen.Bounds.Width, 100)) {
Placeholder = _placeHolderText,
BorderStyle = UITextBorderStyle.Line
};
textView1.EditingDidBegin += (object sender, EventArgs e) =>
{
textView1.Placeholder = string.Empty;
};
textView1.EditingDidEnd += (object sender, EventArgs e) =>
{
textView1.Placeholder = _placeHolderText;
};

var textView2 = new UITextField (new CGRect (0, textView1.Frame.Bottom, UIScreen.MainScreen.Bounds.Width, 100)) {
Placeholder = _placeHolderText,
BorderStyle = UITextBorderStyle.Line
};

this.View.AddSubviews (textView1, textView2);
}

关于c# - Xamarin iOS 在点击时隐藏占位符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32432578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com