ios - UITableViewCell 用动画填充颜色

标签 ios uicolor uitableview ios-animations

从右端开始,我要在UITableViewCell中填充颜色(或者说得更好一点,在很短的时间内从右到左改变UITableViewCell的背景)。我怎样才能做到这一点?

最佳答案

这很容易。

只需在背景中放置一个 View ,从 0 宽度开始,在 tableview/tableview 单元格的右侧,然后将其动画到父 View 的整个宽度。

代码片段(以 Swift 游乐场的形式)

导入 UIKit
导入 XCPlayground

let tableView = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 200))
tableView.backgroundColor = UIColor.whiteColor()

var animatedBackroundColorView = UIView(frame: CGRect(x: tableView.frame.width, y: tableView.frame.origin.y, width: tableView.frame.width, height: tableView.frame.height))
animatedBackroundColorView.backgroundColor = UIColor.orangeColor()
tableView.addSubview(animatedBackroundColorView)
UIView.animateWithDuration(1) { () -> Void in
    animatedBackroundColorView.frame = tableView.frame
}
XCPShowView("identifier", view: tableView)

转载:enter image description here

关于ios - UITableViewCell 用动画填充颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35913355/

相关文章:

ios - 如何在iOS中使用Flutter StandardMessageCodec写入/读取二进制数据?

ios - 从语音备忘录应用程序通过 “open in:” 导出音频文件

ios - 更改导航栏色调颜色 iOS 7。

iOS ACEDrawingView 无法设置 RGB 颜色,只能设置默认的 UIColor 值

ios - 如何将数据从 UITableViewCell 传递到 ViewController?

ios - Iphone 删除 subview

iphone - TableView addGesture 到 UIImageView 以了解哪个单元格被点击

swift - UIColor 初始值设定项(无法找到接受 .... 的类型 'UIColor' 的初始值设定项)错误

ios - UITableViewCell背景图片设置

ios - 在 iOS 中设置 textView 上字母的格式