Ios 基于选择的TableView动画

Ios 基于选择的TableView动画,ios,iphone,swift,uitableview,Ios,Iphone,Swift,Uitableview,我得到了这段代码-我想为自定义表视图单元格的UIView的宽度变化设置动画-以下是我在CustomTableViewCell类中实现的内容: var expanded: Bool = false override func layoutSubviews() { super.layoutSubviews() if !expanded { horizontalProgressView.hidden = true } else { hor

我得到了这段代码-我想为自定义表视图单元格的UIView的宽度变化设置动画-以下是我在CustomTableViewCell类中实现的内容:

var expanded: Bool = false    
override func layoutSubviews() {
    super.layoutSubviews()
    if !expanded {
        horizontalProgressView.hidden = true
    } else {
        horizontalProgressView.hidden = false
        horizontalProgressView.frame.size.width = 100.0
    }
}
然后,在实现了tableView和委托/数据源的viewController中,我尝试:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    let cell = tableView.cellForRowAtIndexPath(indexPath) as! CustomTableViewCell
    cell.expanded = true
}

当我选择单元格时,horizontalProgressView可见(因此.hidden部分起作用),但宽度仍然与我在故事板中设置的宽度相同。我遗漏了什么?

故事板的宽度是多少?还有,为什么不使用自动布局呢?我的故事板宽度为5.0。无约束。
horizontalProgressView.layoutifneed()
cell.expanded=true
之后?我已经尝试过了-不起作用。我放弃了这种方法,直接在didSelectRowAtIndexPath中使用UIView.animateWithDuration。很好。我只是想知道如何以不同的方式实现它。谢谢故事板的宽度是多少?还有,为什么不使用自动布局呢?我的故事板宽度为5.0。无约束。
horizontalProgressView.layoutifneed()
cell.expanded=true
之后?我已经尝试过了-不起作用。我放弃了这种方法,直接在didSelectRowAtIndexPath中使用UIView.animateWithDuration。很好。我只是想知道如何以不同的方式实现它。谢谢