【问题标题】:Horizontal collection view with stack view inside a stack view hide inner stack view on reload with animation在堆栈视图内具有堆栈视图的水平集合视图在重新加载动画时隐藏内部堆栈视图
【发布时间】:2020-01-09 10:32:54
【问题描述】:

您好,我有一个集合视图,它有一个集合视图单元格,其中一个外部堆栈视图包含一个 uibutton 和另一个堆栈视图。

当我单击单元格中的 uibutton 时,它是一个可折叠的集合视图,它必须用动画隐藏内部堆栈视图。如何做到这一点

Collection view cell
   Content view
     Stack view
        Uibutton
        Stack view

我想在选择 UI 按钮时用动画隐藏内部堆栈视图

Cell Code

func setupUI(_ hidden: Bool, filter: Filter) {

    self.filter = filter

    UIView.performWithoutAnimation {
        expandableStackView.isHidden = hidden ? false : true
        self.filterTitleButton.setTitle(filter.filterTitle, for: .normal)
    }
}

在控制器单元格中,我将调用此 setUpUI 函数

【问题讨论】:

  • 显示你尝试过的代码
  • @Anbu 我更新了问题,请检查。隐藏工作正常,当我没有动画时。但我想取消隐藏堆栈视图,就像它应该在选中时向右滑动,并在未选中时用左滑动画移到按钮后面

标签: ios swift uitableview uicollectionview custom-cell


【解决方案1】:
UIView.animate(withDuration: 3,
                   delay: 0.0,
                   usingSpringWithDamping: 0.9,
                   initialSpringVelocity: 1,
                   options: [],
                   animations: {
                        innerStackView.hidden = true
                        stackView.layoutIfNeeded()
                    },
                   completion: nil)

这里还有你可以使用的扩展 https://stackoverflow.com/a/53517910/1780632

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-26
    • 1970-01-01
    • 2018-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多