简体   繁体   中英

Value of type 'ImageSlideshow?' has no member 'pageControlBottomPadding'

When upgrade from swift3 to swift4, I have this error: Value of type ImageSlideshow? has no member pageControlBottomPadding

I use xcode10.1, swift4, target ios9.0 and above. ImageSlideshow version is 1.7.0.

There are also warnings: 'pageControl' is deprecated: Use pageIndicator.view instead

I think it might because the member name changed in swift4, the pageControl and its members are no longer used, and tried changing pageControl to pageIndicator or pageIndicator.view ,

But I searched and cannot find the corresponding member name of currentPageIndicatorTintColor and pageIndicatorTintColor and pageControlBottomPadding

Here's my code:

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

截图图片

Any idea what new name should I use? Or is there a way I can still use "pageControl" in swift4? Thank you very much.

pageControl is deprecated in the latest version of ImageSlideshow.

The example from the library's github indicates that you should use pageControl like below. This will also get your deprecated warnings fixed:

@IBOutlet var slideshow: ImageSlideshow!

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

slideshow.pageIndicator = pageControl

To fix the error, use the following:

slideshow.pageIndicatorPosition = .init(horizontal: .center, vertical: .customBottom(padding: 30))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM