Hola estoy teniendo un problema, quiero que el botón "buttonEnab" aparezca cuando este el ultimo slide (slide4). eh realizado pruebas pero no han funcionado.
class ViewController: UIViewController, UIScrollViewDelegate {
@IBOutlet weak var scrollView: UIScrollView!{
didSet{
scrollView.delegate = self
}
}
@IBOutlet weak var pageControl: UIPageControl!
@IBOutlet weak var buttonEnab: UIButton!
var slides:[Slide] = [];
override func viewDidLoad() {
super.viewDidLoad()
slides = createSlides()
setupSlideScrollView(slides: slides)
pageControl.numberOfPages = slides.count
pageControl.currentPage = 0
view.bringSubviewToFront(pageControl)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func createSlides() -> [Slide] {
let slide1:Slide = Bundle.main.loadNibNamed("Slide", owner: self, options: nil)?.first as! Slide
slide1.imageView.image = UIImage(named: "caja_zero")
slide1.labelTitle.text = "Titulo Tutorial UNO"
slide1.labelDesc.text = "Descripcion turial uno. realizar paquete"
let slide2:Slide = Bundle.main.loadNibNamed("Slide", owner: self, options: nil)?.first as! Slide
slide2.imageView.image = UIImage(named: "caja_zero")
slide2.labelTitle.text = "Titulo Tutorial Dos"
slide2.labelDesc.text = "Descripcion tutorial dos."
let slide3:Slide = Bundle.main.loadNibNamed("Slide", owner: self, options: nil)?.first as! Slide
slide3.imageView.image = UIImage(named: "caja_zero")
slide3.labelTitle.text = "Titulo Tutorial TRES"
slide3.labelDesc.text = "Descripcion tutorial tres"
let slide4:Slide = Bundle.main.loadNibNamed("Slide", owner: self, options: nil)?.first as! Slide
slide4.imageView.image = UIImage(named: "caja_zero")
slide4.labelTitle.text = "Titulo tutorial 4"
slide4.labelDesc.text = "Descripcion tutorial cuatro"
return [slide1, slide2, slide3, slide4]
}
// aplicar los slides
func setupSlideScrollView(slides : [Slide]) {
scrollView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height)
scrollView.contentSize = CGSize(width: view.frame.width * CGFloat(slides.count), height: view.frame.height)
scrollView.isPagingEnabled = true
for i in 0 ..< slides.count {
slides[i].frame = CGRect(x: view.frame.width * CGFloat(i), y: 0, width: view.frame.width, height: view.frame.height)
scrollView.addSubview(slides[i])
}
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let pageIndex = round(scrollView.contentOffset.x/view.frame.width)
pageControl.currentPage = Int(pageIndex) }
@IBAction func buttonEnabTapped(slides : [Slide]) {
}
}