Tag: collections

在Collectionview中如何根据select设置颜色?

我的要求是设置默认颜色在第一个indexPath ,我想改变颜色根据select。 我的要求是当collectionview在第一次加载索引时,背景颜色应该是红色,而取消select的颜色是蓝色。 如何pipe理这是我的代码 import UIKit class MyCollectionViewCell: UICollectionViewCell { override var selected: Bool { didSet { contentView.backgroundColor = selected ? UIColor.redColor(): UIColor.blueColor() } } } class ViewController: UIViewController { @IBOutlet var collView: UICollectionView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func […]

Swift Collection低估了使用量

什么是集合underestimateCount的用例。 文档说它具有与标准收集计数相同的复杂性。 我已经看到了它的声明: /// Returns a value less than or equal to the number of elements in /// `self`, *nondestructively*. /// /// – Complexity: O(N). public func underestimateCount() -> Int 但它并没有告诉我什么时候应该使用它,什么原因。