gpt4 book ai didi

ios - 如何使Pageviewcontroller背景透明

转载 作者:行者123 更新时间:2023-11-30 11:38:49 25 4
gpt4 key购买 nike

如何使Pageviewcontroller背景透明,我试图让它变得透明

  super.viewDidLoad()

self.pageviewcontroller = self.storyboard?.instantiateViewController(withIdentifier: "PageViewController") as! UIPageViewController
self.pageviewcontroller.dataSource = self
self.pageviewcontroller.delegate = self
var pageControl = UIPageControl()
pageControl = UIPageControl.appearance()
pageControl.backgroundColor = .clear
pageControl.pageIndicatorTintColor = .gray
pageControl.currentPageIndicatorTintColor = UIColor(red: 0.00, green: 1.0, blue: 1.0, alpha: 1.0)
pageControl.backgroundColor = UIColor.clear

ViewControllers.append(
UIStoryboard(name: "Main", bundle: nil) .
instantiateViewController(withIdentifier: "DashboardViewController") as! BaseViewController)




ViewControllers.append(
UIStoryboard(name: "Main", bundle: nil) .
instantiateViewController(withIdentifier: "qwertyViewController") as! BaseViewController)
if let firstViewController = ViewControllers.first {

trying to making that controller as transparent

after adding pagecontrol

最佳答案

我测试了以下代码并且它有效

This is my controller class:

class PageViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {

In that class I've created this variable:

lazy var pageArra: [UIViewController] = {
return[self.VCInstance("ONE"),self.VCInstance("TWO"),self.VCInstance("THREE"),self.VCInstance("FOUR")]
}()

Which uses this function to get the storyboard assets. I gave 4 ViewControllers the ID's listed above

private func VCInstance(_ name: String) -> UIViewController {
return UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: name)
}

This is my viewDidLoad:

override func viewDidLoad() {
super.viewDidLoad()
dataSource = self
delegate = self
var pageControl = UIPageControl()
pageControl = UIPageControl.appearance()
pageControl.pageIndicatorTintColor = .gray
pageControl.currentPageIndicatorTintColor = UIColor(red: 0.00, green: 1.0, blue: 1.0, alpha: 1.0)
}

And This is how I get it to clear when it loads

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if view is UIScrollView {
view.frame = UIScreen.main.bounds
} else if view is UIPageControl {
view.backgroundColor = .clear
}
}

加上所有数据源和委托(delegate)所需的方法

关于ios - 如何使Pageviewcontroller背景透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49450239/

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