Ich habe eine einfache UICollectionViewController, die X Menge an Zellen zurückgibt. Ich möchte es so haben, wenn eine Zelle ausgewählt wird, wird diese spezifische ausgewählte Zelle ihre Größe ändern und in der Höhe größer werden, da alle anderen Zellen gleich bleiben. Wie erreiche ich das? Hier ist mein Code:Ändern der Größe der ausgewählten UICollectionView-Zelle
class HomeController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
let cellId = "cellId"
override func viewDidLoad() {
super.viewDidLoad()
collectionView?.backgroundColor = UIColor(white: 0.90, alpha: 1.0)
collectionView?.register(PostCell.self, forCellWithReuseIdentifier: cellId)
collectionView?.showsVerticalScrollIndicator = false
collectionView?.alwaysBounceVertical = true
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 4
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as! PostCell
return cell
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let height = (view.frame.width) * 9/16
return CGSize(width: view.frame.width, height: height + 50 + 50)
}
}
Könnten Sie bitte ein Beispiel geben? Vielen Dank. –
Sure arbeitet jetzt an einem – Callam
Danke Mann. Schätze es wirklich. –