【问题标题】:Transparent view while navigatiing导航时的透明视图
【发布时间】:2013-09-21 09:54:14
【问题描述】:

从一个视图导航到另一个视图时,我想让第二个视图透明。即导航后第一个视图内容应该是可见的。

我试过通过背景颜色清晰和透明背景图像。但在导航时它是透明的。

完全导航后,第二个视图背景变为黑色。

这是我的代码,

 obj=[[loginViewController alloc]initWithNibName:@"loginViewController" bundle:nil];
 [self presentModalViewController:obj animated:YES];  

【问题讨论】:

  • 它通常的行为......相反,您可以在第一个视图控制器上采取透明视图

标签: iphone ios objective-c presentmodalviewcontroller


【解决方案1】:

只有subview第二个视图才能实现。

通过使用 presentmodalviewcontrollerpushviewcontroller ,您的 firstview 将不可见。

Secondview *second = [[Secondview alloc] initWithNibName:@"Secondview"  bundle:nil];
 [self.view addSubview:second.view];

    CATransition *animation = [CATransition animation];
    [animation setType:kCATransitionPush];
    [animation setSubtype:kCATransitionFromBottom];
    [[self.view layer] addAnimation:animation forKey:@"transitionViewAnimation"];

【讨论】:

  • 那我怎样才能让动画从底部向上
  • 我已经对答案进行了更改,现在试试。我忘了添加 second.view 当你 addsubview 这个视图。
【解决方案2】:

解决方案是覆盖 drawRect: 并处理其中的 alpha。你不能触摸 UIView 的 alpha 属性,也不能将视图的背景颜色设置为任何透明的东西。所有绘图必须在 drawRect: 中进行。通过这种方式,我能够在顶部堆叠透明视图和 pup 不透明元素。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-21
    • 2010-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-08
    相关资源
    最近更新 更多