gpt4 book ai didi

iOS 如何在容器 View Controller 中设置透明

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:02:24 25 4
gpt4 key购买 nike

我在 Root View Controller 中嵌入了 UIPageViewController。

喜欢下面的照片。

enter image description here

但我想设置第一,第二个 View Controller 背景透明,它仍然可以显示 View Controller 文本 1 和 2。

所以它将显示根背景颜色(黑色)并且 Root View Controller 可以通过 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 view] setBackgroundColor:[UIColor clearColor]];

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

关于iOS 如何在容器 View Controller 中设置透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28233139/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com