1

I have a UIViewController with 2 main subviews. One subview is UIViewController and the other is a DialogViewController. The DialogViewController contains a few elements. I have a custom background that I would like to assign behind the DVC so when the user scrolls up or down, the background is shown until they release their finger or mouse and the view bounces back into its original position.

The problem is, when I assign the background using the method I have found through searching, the elements appear clear and show the background through them when the view loads. However, when I scroll enough to push the element off of the screen before bouncing back, the element's background then goes back to white. I want my elements to always be white and have only the background as my custom image.

The code I have used to try to achieve this is as follows:

// Declare my background
UIImage background = UIImage.FromBundle("images/background.png");

// Assign background pattern to dvc's ParentViewController -- which is my NavigationController (Not sure if this is what it should be)

dvc.TableView.BackgroundColor = UIColor.Clear;
dvc.ParentViewController.View.BackgroundColor = UIColor.FromPatternImage(background);

I have also tried assigning to the dvc.TableView.BackgroundView with no luck.

Any tips would be much appreciated.

mp501
  • 666
  • 8
  • 12

1 Answers1

0

Maybe this works:

UIView background = new UIView(dvc.TableView.Bounds);
background.BackgroundColor = UIColor.Green;

dvc.TableView.BackgroundView = background;

If you have many other "Roots" in the dvc you have to subclass UINavigationControllerDelegate and to override the "WillShowViewController". Just put the code into this method.

Alex
  • 459
  • 3
  • 14