0

In TvOS, I can't seem to get a UITextField to render with a clear background. Please note I am also using Xamarin as an intermediary.

var label = new UITextField()
{
    Text = seperator,
    UserInteractionEnabled = false,
    BackgroundColor = UIColor.Clear,
    VerticalAlignment = UIControlContentVerticalAlignment.Top
};

parent.AddArrangedSubview(label);

label.TranslatesAutoresizingMaskIntoConstraints = false;
label.HeightAnchor.ConstraintEqualTo(200).Active = true;
label.TextAlignment = UITextAlignment.Center;

The parent in this case is a UIStackView.

Here is the output: enter image description here

It seems to work perfectly fine if you set it to any other color.

Any solutions would be greatly appreciated.

Bart
  • 367
  • 2
  • 11
  • Why not use a UILabel? – Jason Oct 26 '22 at 17:33
  • For the reason that I need the text to be top aligned. – Bart Oct 26 '22 at 17:37
  • https://stackoverflow.com/questions/1054558/vertically-align-text-to-top-within-a-uilabel – Jason Oct 26 '22 at 17:43
  • doesn't seem to work inside a StackView – Bart Oct 26 '22 at 23:18
  • According to the picture you provided, you have set a clear background in UITextField, its background color is also black, and the function of clear has been realized. Can you tell me what effect you want? – Zack Oct 31 '22 at 08:49
  • I guess clear != transparent in Apple world? @DongzhiWang-MSFT – Bart Oct 31 '22 at 17:13
  • @Bart You can check [Apple Developer doc](https://developer.apple.com/documentation/uikit/uicolor/1621945-clearcolor?language=objc#:~:text=systemGray6Color-,Transparent%20color,-P), the header of clearColor is Transparent color. – Zack Nov 01 '22 at 05:53

0 Answers0