Detect Start and Stop Editing UITextView

后端 未结 4 1714
名媛妹妹
名媛妹妹 2021-02-06 22:39

How can I call some code upon entering a UITextView (user taps to edit it) and leaving the view (user taps to leave it)?

Appreciate any help.

4条回答
  •  隐瞒了意图╮
    2021-02-06 23:18

    txtviewaddress.text="Address"
    
    txtViewAddress.TextColor = UIColor.LightGray;
    txtViewAddress.ShouldBeginEditing += (textView) =>
            {
     txtViewAddress.Text = "";
                txtViewAddress.TextColor = UIColor.Black;
                return true;
    };
    txtViewAddress.ShouldEndEditing += (textView) =>
            {
                if (textView.Text == "")
                {
                    txtViewAddress.Text = " Address";
                    txtViewAddress.TextColor = UIColor.LightGray;
    
                }
                return true;
            };
    

提交回复
热议问题