从右端开始,我要在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)
转载:
关于ios - UITableViewCell 用动画填充颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35913355/