gpt4 book ai didi

ios - 如何使用 UIPageVIewController 以及如何更改 PageControl 的背景? - swift

转载 作者:行者123 更新时间:2023-11-28 06:45:40 33 4
gpt4 key购买 nike

开门见山,我想学习如何在 Swift 中使用 UIPageViewController,以及如何在实现以下两个函数时更改给定的 PageControl 的背景:

func presentationCountForPageViewController(pageViewController: UIPageViewController) -> Int {
}

func presentationIndexForPageViewController(pageViewController: UIPageViewController) -> Int {
}

这是我在 github 上找到的一个项目的链接,该项目存在 PageControl 背景问题,即使 ViewController 的背景设置为图像,PageControl 仍保留其自己的背景颜色。 ( https://github.com/scroll318is/MyWeatherApp )

PageControl Problem Image

我找到了一个答案,它只改变了对某人有用的背景颜色问题,但它是用 Objective-C 编写的,我不知道如何实现它,因为我是初学者,我只知道 Swift。另外,我希望它与我张贴的任何图片具有相同的背景。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { 
pageControl.backgroundColor = [UIColor clearColor];
UIPageControl *pageControl = [UIPageControl appearance];
pageControl.pageIndicatorTintColor = [UIColor whiteColor];
pageControl.currentPageIndicatorTintColor = [UIColor redColor];
}

由于我是编程新手,所以我尝试四处寻找教程,但我发现的唯一一个正是我想要的教程是 Vea Software 提供的关于 UIPageViewController 的 Youtube 教程。但是它已经过时了,因为它是用 Xcode 6.2 编写的,他没有解释为什么调用某些函数。

有谁知道为什么调用某些函数或知道我在哪里可以学习 UIPageViewController,尤其是如何更改 PageControl 的背景?

几天来我一直在研究 Github 的教程和 repo,试图理解为什么调用某些函数,但我很难理解任何东西。

我看过在线、Youtube、Stackoverflow 和 Apple 的文档,但我在网上找到的教程和 Youtube 并没有深入探讨逻辑,Stack 上的资源主要是我正在使用的 Objective-C转换为 swift 很麻烦,而且 Apple 的文档不会告诉您如何调用它们,除非我只是没找对地方。

抱歉,描述太长了,感谢大家的帮助。

最佳答案

这应该可以帮助您掌握它:https://spin.atomicobject.com/2015/12/23/swift-uipageviewcontroller-tutorial/

完成该教程后,您可能想尝试这个 (http://www.theappguruz.com/blog/easy-steps-to-implement-uipageviewcontroller-in-swift) 以掌握在每个 View 中做更多事情的窍门。

关于ios - 如何使用 UIPageVIewController 以及如何更改 PageControl 的背景? - swift ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36512514/

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