How to make the background color of a tableview transparent?

zs.5950zs.5950 USMember, University

I have a tableview controller in a container view. The container view itself is in a UIViewController . The container occupy only a part of the UIViewController. My goal is to make the tableview and the tableview cell transparent so that the background image of the UIViewController can be visible . How can I do that?

Answers

  • KymPhillpotts.3866KymPhillpotts.3866 AUXamarin Team, University, XamUProfessors Xamurai

    Are you doing this in Storyboard or Code?

  • rene_ruppertrene_ruppert DEXamarin Team, University, XamUProfessors Xamurai

    It's hard to picture what you are trying to do. Can you maybe give us a (preferably working) code sample? What have you tried so far?

    Basically you'd just have to set the BackgroundColor = UIColor.Clear on your views.

  • zs.5950zs.5950 USMember, University

    I am tried in code and in the storyboard and nothing so far .

    The following code is the ViewDidLoad() of my container view

    public override void ViewDidLoad ()
    {
    UIStoryboard storyboard = UIStoryboard.FromName ("Main", null);
    var tableViewController = storyboard.InstantiateViewController ("myTableViewController");

            this.AddChildViewController (tableViewController);
            this.View.AddSubview (tableViewController.View);
        }
    

    And the code of the ViewDidLoad() of my tableview is

    public override void ViewDidLoad ()
    {

            TableView.BackgroundColor = UIColor.Clear;
    
            loginCell.BackgroundColor = UIColor.Clear;
            loginCell.ContentView.BackgroundColor = UIColor.Clear;
            loginCell.BackgroundColor = UIColor.FromWhiteAlpha (1.0f, 0.5f);
    
    
        //  loginCell.BackgroundView = new UIView ();
        //  loginCell.BackgroundView.BackgroundColor = UIColor.Clear;
    
    
        }
    

    In the preceding code the loginCell is the name of a cell that I set in the styoryboard

  • zs.5950zs.5950 USMember, University

    I am tried in code and in the storyboard and nothing so far .

    The following code is the ViewDidLoad() of my container view

    public override void ViewDidLoad ()
    {
        UIStoryboard storyboard = UIStoryboard.FromName ("Main", null);
        var tableViewController = storyboard.InstantiateViewController ("myTableViewController");
    
            this.AddChildViewController (tableViewController);
            this.View.AddSubview (tableViewController.View);
    }
    

    And the code of the ViewDidLoad() of my tableview is

    public override void ViewDidLoad ()
    {
    
            TableView.BackgroundColor = UIColor.Clear;
    
            loginCell.BackgroundColor = UIColor.Clear;
            loginCell.ContentView.BackgroundColor = UIColor.Clear;
            loginCell.BackgroundColor = UIColor.FromWhiteAlpha (1.0f, 0.5f);
    
    
        //  loginCell.BackgroundView = new UIView ();
        //  loginCell.BackgroundView.BackgroundColor = UIColor.Clear;
    

    }

    In the preceding code the loginCell is the name of a cell that I set in the storyboard

Sign In or Register to comment.