Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios CAShapeLayer动画问题_Ios_Uikit_Calayer_Cashapelayer_Ios Animations - Fatal编程技术网

Ios CAShapeLayer动画问题

Ios CAShapeLayer动画问题,ios,uikit,calayer,cashapelayer,ios-animations,Ios,Uikit,Calayer,Cashapelayer,Ios Animations,我有一个CAShapeLayer(下图),用来画泡泡。根据设计,这一切都很好,但当我开始在tableView中使用tableView.BeginUpdate()和tableView.endUpdates()调整它的大小时。我的旧图层暂时变成了黑色。这看起来很糟糕。我真的很困惑如何解决这个问题。它有点像是黑色的图层,填充物像面具一样涂在上面。 我尝试了几种方法,比如在不同的地方添加/删除图层。等等,但结果总是这样 你的解决方案行不通绘制(:)。在UITableView结束动画后,它是在table

我有一个CAShapeLayer(下图),用来画泡泡。根据设计,这一切都很好,但当我开始在tableView中使用tableView.BeginUpdate()和tableView.endUpdates()调整它的大小时。我的旧图层暂时变成了黑色。这看起来很糟糕。我真的很困惑如何解决这个问题。它有点像是黑色的图层,填充物像面具一样涂在上面。 我尝试了几种方法,比如在不同的地方添加/删除图层。等等,但结果总是这样


你的解决方案行不通<在动画块期间不调用代码>绘制(:)。在UITableView结束动画后,它是在tableView.endUpdates()之后绘制的

Draw(:)
-我认为你根本不应该根据自己的需要使用它

如果我可以向您推荐一些解决方案:

1) 在
awakeFromNib
中:

override func awakeFromNib() {
    super.awakeFromNib()

    self.contentView.backgroundColor = self.shapeColor
    self.contentView.layer.cornerRadius = 15

    /** make  left view and attach it to the left bottom anchors with fixed size and draw into this view the shape of your left arrow***/
    self.leftArrowView.isHidden = self.isReverted
    /** make  right view and attach it to the right bottom anchors with fixed size and draw into this view the shape of your right arrow***/
    self.rightArrowView.isHidden = !self.isReverted
}
2) 在
prepareforeuse
中:

override func prepareForReuse() {
    super.prepareForReuse()
    self.leftArrowView.isHidden = self.isReverted
    self.rightArrowView.isHidden = !self.isReverted
}

这将导致您的手机大小平稳变化。

很抱歉,今天我才有机会测试一下。我刚刚试过这个,我仍然有同样的问题。问题不在于箭头,而在于单元格高度的变化。这是动画,或摆脱黑色的形状。(你有没有看到难以解释的视频)
override func prepareForReuse() {
    super.prepareForReuse()
    self.leftArrowView.isHidden = self.isReverted
    self.rightArrowView.isHidden = !self.isReverted
}