选择单元格时,将隐藏圆圈uiview。怎么解决? 带来SubSubviewToFront没有帮助。
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
self.selectedBackgroundView?.bringSubviewToFront(statusView)
}
请帮忙!
答案 0 :(得分:0)
通过覆盖backgroundColor
和func setHighlighted(highlighted: Bool, animated: Bool)
设置您的视图func setSelected(selected: Bool, animated: Bool)
,如下所示:
class Cell: UITableViewCell {
var redView :UIView!
var yellowView :UIView!
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
redView = UIView()
redView.frame = CGRect(x: 0, y: 10, width: 100, height: 20)
self.contentView.addSubview(redView)
yellowView = UIView()
yellowView.frame = CGRect(x: 200, y: 10, width: 100, height: 20)
self.contentView.addSubview(yellowView)
redView.backgroundColor = UIColor.redColor()
yellowView.backgroundColor = UIColor.yellowColor()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
redView.backgroundColor = UIColor.redColor()
yellowView.backgroundColor = UIColor.yellowColor()
}
override func setHighlighted(highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
redView.backgroundColor = UIColor.redColor()
yellowView.backgroundColor = UIColor.yellowColor()
}
}
答案 1 :(得分:0)
在选择单元格UIView时,所有单元格都在单元格的背景中绘制,因此隐藏了UIView。如果在选择后重新绘制,那么一切都将成为。
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
if selected {
switch status {
case "8","9":
// print("Cancel")
statusView.backgroundColor = FlatUIColors.thunderBirdColor()
case "10","11","12":
// print("Success")
statusView.backgroundColor = FlatUIColors.nephritisColor()
case "20","21","22","23":
// print("Wait")
statusView.backgroundColor = FlatUIColors.wetAsphaltColor()
case "30","31":
// print("Processing")
statusView.backgroundColor = FlatUIColors.peterRiverColor()
default:
break
}
}
}