【问题标题】:How do you use UIPageVIewController and how can I change background of the PageControl? - Swift您如何使用 UIPageVIewController 以及如何更改 PageControl 的背景? - 斯威夫特
【发布时间】:2016-04-09 03:46:52
【问题描述】:

直截了当,我想学习如何在 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,试图理解为什么调用某些函数,但我很难理解任何东西。

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

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

【问题讨论】:

    标签: ios objective-c swift uipageviewcontroller uipagecontrol


    【解决方案1】:

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

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

    【讨论】:

    • 我会检查一下谢谢!顺便说一句,您知道如何更改 UIPageViewController 点的背景吗?我在一些在线教程中看到的唯一方法是实现一个 PageControl 出口并更改为子视图以使其位于顶部,但我想避免这种情况并尝试使用已经使用 UIPageViewController 自动实现的点
    • @RichardCuico 从第一个教程链接的 cmets 部分查看第一个和第二个 cmets。有一种非常快速的方法来设置页面点的样式!如果找不到,请告诉我。
    • 太棒了,我看到了!我会尽快实现它。如果在学校的最后几周,我目前有很多工作,所以我可能需要一段时间才能尝试一下,但当我这样做时,我一定会回复并发布我的结果。谢谢约翰!
    猜你喜欢
    • 1970-01-01
    • 2016-06-01
    • 2014-08-31
    • 1970-01-01
    • 1970-01-01
    • 2017-05-26
    • 2020-11-01
    • 2017-07-22
    • 2017-03-24
    相关资源
    最近更新 更多