折叠并展开tableView中的视图

时间:2016-09-06 15:58:41

标签: ios swift uitableview animation constraints

我想在tableView中展开和折叠视图。观看了这个视频:

UNUserNotificationCenterDelegate docs

ishidden = true无法正常工作,因为高度仍在那里

  func expandCollapse(sender:UIButton) {

    let collapseImage = UIImage(named: "collapse")
    let expandImage = UIImage(named: "expand")

    let row = sender.tag
    let indexPath = NSIndexPath(forRow: row, inSection: 0)

    let cell = self.table.cellForRowAtIndexPath(indexPath) as! ArchiveViewCell


    if (sender.currentImage == UIImage(named: "expand")) {
        sender.setImage(collapseImage, forState: UIControlState.Normal)

        cell.moreViewHeight.priority = 1
        cell.moreViewHeight.constant = 0

        cell.moreView.layoutIfNeeded()

    } else {
        sender.setImage(expandImage, forState: UIControlState.Normal)

        cell.moreViewHeight.priority = 999
        cell.moreView.layoutIfNeeded()

    }

0 个答案:

没有答案