iphone - IOS:如何为缩进级别的变化设置动画?

标签 iphone ios cocoa-touch

我有一个 UITableView,其中一些行使用 indentationLevel 缩进。单元格具有 UITableViewCellStyleValue1 样式,因此我缩进了 textLabel 而不是 detailTextLabel。有时我想更改一行的缩进,以便文本向左或向右移动。设置 indentationLevel 有效,但文本突然跳转:我怎样才能让它流畅地动画化?

最佳答案

这有效 - 通过 indentDelta 改变缩进:

CGRect frame = cell.textLabel.frame;
frame.origin.x += indentDelta * cell.indentationWidth;
[UIView animateWithDuration:0.5f animations:^{
    cell.textLabel.frame = frame;
} completion:^(BOOL finished){
    cell.indentationLevel = cell.indentationLevel + indentDelta;
}];

首先,标签平滑地滚动到我想要的位置,然后使用正确的截断重新绘制行,并留下正确的缩进级别,以便在重新生成时正确绘制,例如如果点击选择。

关于iphone - IOS:如何为缩进级别的变化设置动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7974632/

相关文章:

ios - 按钮操作不适用于 subview

cocoa-touch - 当触摸发生在表单之外时,如何关闭显示为 "Form Sheet"的模态视图 Controller ?

iphone - iOS:Facebook 发布隐私

ios - 来自 iOS 的 Instagram 签名 API 调用

ios - 修改正在运行的 SKAction 的速度

iphone - 为什么图像没有显示在 UIImageView 中

ios - 如何为 UILabel 制作马车

iphone - iPhone 上的网络接口(interface)名称?

ios - 故意使存档失败的代码

ios - `Realm` 需要 CocoaPods 版本 `>= 1.10` ,您当前的版本不满足, `1.8.3`