1

我有一个UIViewController与2个主要子视图。一个子视图是UIViewController,另一个是DialogViewController。 DialogViewController包含一些元素。我有一个自定义背景,我希望在DVC背后分配,因此当用户向上或向下滚动时,会显示背景,直到他们松开手指或鼠标并将视图弹回原始位置。单击 - DialogViewController的TableView背景更改元素的背景以及

问题是,当我使用我通过搜索找到的方法分配背景时,元素显示为清晰并在视图加载时显示背景。但是,当我滚动到足以将元素从屏幕上弹出之前,元素的背景会变回白色。我希望我的元素始终是白色的,并且只有背景作为我的自定义图像。

我已经习惯了尝试实现这一目标是如下代码:

// 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); 

我自己也尝试没有运气分配给dvc.TableView.BackgroundView。

任何提示将不胜感激。

回答

0

也许这个作品:

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

dvc.TableView.BackgroundView = background; 

如果你有,你必须继承UINavigationControllerDelegate 和覆盖“WillShowViewController”的DVC许多其他的“根”。只需将代码放入此方法即可。