3

从 swift3 升级到 swift4 时出现此错误:Value of type ImageSlideshow?has no memberpageControlBottomPadding

我使用xcode10.1,swift4,目标ios9.0及以上。ImageSlideshow版本是 1.7.0。

还有warnings: 'pageControl' is deprecated: Use pageIndicator.view instead

我认为这可能是因为成员名称在 swift4 中更改,不再使用 pageControl 及其成员,并尝试更改pageControlpageIndicatoror pageIndicator.view

currentPageIndicatorTintColor但是我搜索并没有找到andpageIndicatorTintColor和的对应成员名 pageControlBottomPadding

这是我的代码:

import ImageSlideshow
...
@IBOutlet weak var imageSliderView: ImageSlideshow!
...
imageSliderView.pageControl.currentPageIndicatorTintColor = Color.Laser.instance()
        imageSliderView.pageControl.pageIndicatorTintColor = UIColor.white
        imageSliderView.pageControlBottomPadding = 30.0

截图图像

知道我应该使用什么新名称吗?或者有没有办法我仍然可以在 swift4 中使用“pageControl”?非常感谢。

4

1 回答 1

4

pageControl在最新版本的 ImageSlideshow 中已弃用。

该库的 github 中的示例表明您应该pageControl像下面这样使用。这也将修复您已弃用的警告:

@IBOutlet var slideshow: ImageSlideshow!

let pageControl = UIPageControl()
pageControl.currentPageIndicatorTintColor = UIColor.lightGray
pageControl.pageIndicatorTintColor = UIColor.black

slideshow.pageIndicator = pageControl

要修复错误,请使用以下命令:

slideshow.pageIndicatorPosition = .init(horizontal: .center, vertical: .customBottom(padding: 30))
于 2019-04-22T09:37:18.407 回答