Muh*_*bal 2 xcode animation ios swift uitableviewrowaction
实现闪烁动画时,不会在 UITableViewCell 上执行任何操作,它开始闪烁,正常但不可点击或可滑动。我尝试了一些解决方案,但无法修复。代码如下。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
cell.backgroundColor = UIColor.colorWithHexString(hexStr: "#FDFAEB")
cell.blink()
return cell
}
Run Code Online (Sandbox Code Playgroud)
动画扩展代码:
extension UIView {
func blink() {
self.alpha = 0.5;
UIView.animate(withDuration: 0.7, //Time duration you want,
delay: 0.0,
options: [.curveEaseInOut, .autoreverse, .repeat],
animations: { [weak self] in self?.alpha = 1.0 },
completion: { [weak self] _ in self?.alpha = 0.8 })
}
}
Run Code Online (Sandbox Code Playgroud)
请告诉我,这是什么原因,我该如何解决?
默认情况下,动画期间禁用用户交互。您需要将该.allowUserInteraction选项添加 到您的选项集中。
(请注意,如果您正在为视图的位置设置动画,则用户将无法在视图移动时点击它。在幕后,动画一开始,视图就会跳转到其目标位置。它只会出现在屏幕上移动。如果你想在一个视图在屏幕上移动时处理点击它,它会复杂得多。)
| 归档时间: |
|
| 查看次数: |
32 次 |
| 最近记录: |