"接着"按钮在应用程序中不会消失

时间:2017-06-27 15:24:35

标签: ios swift

下面显示的是我用来使我的下一个按钮消失的代码。但是按钮不会消失。

 func nextPage() {
    //we are on the last page
    if pageControl.currentPage == pages.count {
        moveControlConstraintsOffScreen()

        UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseOut, animations: {
            self.view.layoutIfNeeded()
        }, completion: nil)
    }

    //second last page
    if pageControl.currentPage == pages.count {
       return
    }

    let indexPath = IndexPath(item: pageControl.currentPage + 1, section: 0)
    collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)
    pageControl.currentPage += 1
}

1 个答案:

答案 0 :(得分:0)

在您的链接中,您似乎正在将nextButton添加到view。你需要调用这个方法让它消失。

view.sendSubviewToBack(nextButton)