gpt4 book ai didi

ios - 如何在 Swift 的页面 View 中隐藏点的背景?

转载 作者:行者123 更新时间:2023-11-28 11:15:48 24 4
gpt4 key购买 nike

我目前在删除背景(屏幕底部的栏)方面遇到问题,就像他们在这个 post 中遇到的问题一样

然而,发布的解决方案都是在 Objective-c 中。我试图将它翻译成 Swift,但没有成功。

我也试过把“UIPageControl.appearance()”改成cleancolor,还是不行。

有人可以提供一些提示吗?

谢谢!

我的代码在这里:

import UIKit

class TutorialViewController: UIViewController, UIPageViewControllerDataSource{

var pageViewController: UIPageViewController?
let contentImages = ["Tutorial1.png", "Tutorial2.png","Tutorial3.png"]


override func viewDidLoad() {
super.viewDidLoad()
createPageViewController()
setupPageControl()

// Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

//supporting functions
private func createPageViewController() {

let pageController = self.storyboard!.instantiateViewControllerWithIdentifier("PageController") as! UIPageViewController
pageController.dataSource = self

if contentImages.count > 0 {
let firstController = getItemController(0)!
let startingViewControllers: NSArray = [firstController]
pageController.setViewControllers(startingViewControllers as [AnyObject], direction: UIPageViewControllerNavigationDirection.Forward, animated: false, completion: nil)
}

pageViewController = pageController
addChildViewController(pageViewController!)
self.view.addSubview(pageViewController!.view)
pageViewController!.didMoveToParentViewController(self)
}

private func setupPageControl() {
let appearance = UIPageControl.appearance()
appearance.pageIndicatorTintColor = UIColor.grayColor()
appearance.currentPageIndicatorTintColor = UIColor.whiteColor()
appearance.backgroundColor = UIColor.clearColor()
}

// MARK: - UIPageViewControllerDataSource

func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? {

let itemController = viewController as! PageItemViewController

if itemController.itemIndex > 0 {
return getItemController(itemController.itemIndex-1)
}

return nil
}

func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? {

let itemController = viewController as! PageItemViewController

if itemController.itemIndex+1 < contentImages.count {
return getItemController(itemController.itemIndex+1)
}

return nil
}

private func getItemController(itemIndex: Int) -> PageItemViewController? {

if itemIndex < contentImages.count {
let pageItemController = self.storyboard!.instantiateViewControllerWithIdentifier("TutorialItemController")as! PageItemViewController
pageItemController.itemIndex = itemIndex
pageItemController.imageName = contentImages[itemIndex]
return pageItemController
}

return nil
}

// MARK: - Page Indicator

func presentationCountForPageViewController(pageViewController: UIPageViewController) -> Int {
return contentImages.count
}

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

override func prefersStatusBarHidden() -> Bool {

return true;
}

}

最佳答案

尝试删除此方法

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

它对我来说很快就很好用

关于ios - 如何在 Swift 的页面 View 中隐藏点的背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31913154/

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