【问题标题】:iOS How can I set transparent in Container viewcontrolleriOS 如何在容器视图控制器中设置透明
【发布时间】:2015-01-30 09:48:01
【问题描述】:

我在根视图控制器中嵌入了 UIPageViewController。

如下图。

但我想设置第一、第二个视图控制器背景透明,它仍然可以显示视图控制器文本 1 和 2。

所以它会显示根背景颜色(黑色),并且根视图控制器可以通过 uipageviewcontroller 滑动。

我的pageviewcontroller部分代码如下:

 - (void)viewDidLoad {
[super viewDidLoad];
self.delegate = self;
self.dataSource = self;
pageControl = [UIPageControl appearance];
pageControl.pageIndicatorTintColor = [UIColor lightGrayColor];
pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
pageControl.backgroundColor = [UIColor clearColor];

UIViewController *p1 = [self.storyboard
                        instantiateViewControllerWithIdentifier:@"Intro1ID"];


UIViewController *p2 = [self.storyboard
                        instantiateViewControllerWithIdentifier:@"Intro2ID"];

myViewControllers = @[p1,p2];

[self setViewControllers:@[p1]
               direction:UIPageViewControllerNavigationDirectionForward
                animated:NO completion:nil];

self.modalPresentationStyle = UIModalPresentationCurrentContext;
self.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

}

有没有人可以教我如何将 containerview 背景颜色设置为透明并可以显示 1 、 2 文本? (它是示例代码,所以只有 1、2 文本)

非常感谢。

【问题讨论】:

  • [[p1 view] setBackgroundColor:[UIColor clearColor]];? p2 也一样?
  • 哦哦哦!!你是对的,@Larme。你能输入答案问题吗?我会给你正确的答案。谢谢:P

标签: ios containers transparent


【解决方案1】:

这应该可以解决问题:

[[p1 view] setBackgroundColor:[UIColor clearColor]];
[[p2 view] setBackgroundColor:[UIColor clearColor]];

问题是您的UIViewController 的背景视图不透明。

【讨论】:

    猜你喜欢
    • 2013-09-24
    • 1970-01-01
    • 2013-11-18
    • 2013-10-11
    • 1970-01-01
    • 2017-08-18
    • 2014-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多