- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我希望能够将自定义动画添加到 UITableViewCell 的子类中,这些子类将覆盖以下方法:
override func setHighlighted(highlighted: Bool, animated: Bool) {
}
override func setSelected(selected: Bool, animated: Bool) {
}
和匹配这些方法执行的默认动画的动画曲线和动画持续时间。
换句话说,如何找到Apple提供的当前动画的信息。我需要它来添加我自己的与默认动画完全匹配的自定义动画
最佳答案
您可以在表格 View 中对自定义单元格进行子类化。
在这里,我在 Swift 中创建了一个简单示例,我在其中更改了单元格内标签的值:
import UIKit
class userTableViewCell: UITableViewCell {
@IBOutlet weak var userLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
self.highlighted = false
self.userLabel.alpha = 0.0
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
if selected {
self.highlighted = true
} else {
self.highlighted = false
}
// Configure the view for the selected state
}
override var highlighted: Bool {
get {
return super.highlighted
}
set {
if newValue {
// you could put some animations here if you want
UIView.animateWithDuration(0.7, delay: 1.0, options: .CurveEaseOut, animations: {
self.userLabel.text = "select"
self.userLabel.alpha = 1.0
}, completion: { finished in
print("select")
})
}
else {
self.userLabel.text = "unselect"
}
super.highlighted = newValue
}
}
}
对于 Storyboard ,您必须具备:
关于ios - UITableViewCell setHighlighted, setSelected "animateAlongsideTransition"或类似的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36738334/
什么会导致setHighlighted:animated:被称为触地而不是触地?我有一个非常 slim 的子类 UITableViewCell ,仅由以下方法组成: - (void)awakeFrom
我正在使用 UIButton 来显示表格单元格项目并将其从已读切换为未读。我使用蓝色图像作为背景来显示项目未读的时间,这很有效,但我认为最好使用 setHighlighted 功能,因为它可以节省向应
我的 UITableView 由自定义单元格组成。 我需要完成的是,如果用户点击一个单元格,他们可以看到新的 imageView,当他们抬起手指时,单元格会更新为新图像。反之亦然。 现在,如果我点击一
我是否需要子类化 UITableViewCell 才能使用 setHighlighted?我试图在点击它的那一刻和 Action 发生的那一刻之间将图像覆盖在我的单元格顶部。我曾经通过在自定义 UIT
更新 动画适用于 setEnabled=NO . setEnabled=YES 的动画在 UIScrollView 时触发正在滚动,UIButton位于 setEnabled=NO 的 ScrollV
我在 UITableViewCell 的 contentView 中放置了一个 UIButton 的子类。我遇到的问题是,当我按下按钮并(快速)滚动表格时,按钮的 setHighlighted: 方法
我希望能够将自定义动画添加到 UITableViewCell 的子类中,这些子类将覆盖以下方法: override func setHighlighted(highlighted: Bool, ani
我正在自定义 uitableviewcell 的 -setHighlighted 方法中为自定义单元格着色。效果很好。 但是,我有一些 Controller 想要使用它,而另一些 Controller
在 Swift 中,我重写了单元格的 highlighted 属性以更改它在突出显示时的外观,但当我点击它时它永远不会被调用。 override var highlighted: Bool {
我的重用 UITableViewCell 的 setSelected 看起来像这样(我的 setHighlighted 也是如此): override func setSelected(_ selec
UITableViewCell 中的setHighlighted 和setSelected 有什么区别? 如果我只想在进行选择时不突出显示 cell,我应该重写 setHighlighter 还是只将
有人可以向我解释为什么这些方法 setSelected(_:animated:) 和 setHighlighted(_:animated:)在初始化/加载 TableView 时调用? 我本以为只有在
我是一名优秀的程序员,十分优秀!