我有2个ViewControllers,它们的.m文件都有这个代码:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background"]]];
}
我在两个ViewControllers之间进行推送转换。所以当它在我的iPod上运行时,看起来第二个背景从右到左推送第一个背景。
但这不是我想要的,因为两个ViewControllers的背景都是一样的。我只需要在ViewControllers 1上移动UI组件(按钮,文本字段,标签等),而不是在转换运行时移动背景。
当ViewControllers 2中的UI组件滑入时,只会滑动组件。
如何执行此操作?谢谢..
答案 0 :(得分:3)
试试这个:
[self.navigationController.view setBackgroundColor:<#(UIColor *)#>]
并在viewcontrollers上清除背景:
[self.view setBackgroundColor:[UIColor ClearColor]
答案 1 :(得分:2)
当第一个视图控制器加载时,将背景添加为窗口的子视图插入视图控制器的视图。然后使视图控制器视图透明。要考虑两件事:确保您拥有对它的引用,以便在视图控制器被关闭时删除背景。其次,此背景不会自动旋转,顶部有视图控制器视图。
现在,这是对你问题的直接回答。如果你可以通过做incmiko的建议得到你想要的东西,那么你将是最好的。
答案 2 :(得分:1)
您不必使用2个ViewControllers。使用一个,并将UI组件添加到两个视图中。然后用动画移动它们。
向ViewController添加两个视图。将“First ViewController”UI组件添加到其中任何一个,然后将“Second ViewController”UI组件添加到另一个。用动画移动它们,就像你的后遗症一样。你可以用这个:
[UIView animateWithDuration:0.6 delay:0.
options:UIViewAnimationOptionCurveEaseInOut animations:^{
firstView.center = CGPointMake(Pointx, Pointy);
secondView.center = CGPointMake(Pointx2, Pointy2);
} completion:nil];