Swift cellwilldisplay和uiview动画不工作
我试图在单元格出现后设置高度常数的动画,但什么也没发生。 我在手机上尝试过同样的方法,但还是没有结果。。。你知道我错过了什么吗? 这是我的密码:Swift cellwilldisplay和uiview动画不工作,swift,xcode,Swift,Xcode,我试图在单元格出现后设置高度常数的动画,但什么也没发生。 我在手机上尝试过同样的方法,但还是没有结果。。。你知道我错过了什么吗? 这是我的密码: func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { let cell = cell as! barGraph
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
let cell = cell as! barGraph
UIView.animate(withDuration: 0.5) {
cell.barFillHeightConst.constant = 100
}
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = self.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as! barGraph
cell.label.text = String(indexPath.row)
cell.barFillHeightConst?.isActive = false
cell.barFillHeightConst = cell.barFill.heightAnchor.constraint(equalTo: cell.bar.heightAnchor, multiplier: 0.7)
cell.barFillHeightConst.isActive = true
if indexPath.row % 6 != 0 {
cell.label.textColor = .clear
cell.dotViewConst.width?.constant = 6
cell.dotViewConst.height?.constant = 6
} else {
cell.label.textColor = .lightGray
cell.dotViewConst.width?.constant = 8
cell.dotViewConst.height?.constant = 8
}
cell.dotView.layer.cornerRadius = cell.dotViewConst.width!.constant / 2
return cell
}