Tag: 过渡代理

自定义视图过渡(如新的App Store)

现在,我已经完成了故事板的设置,我创建了一个名为PokemonCell的新文件,并将其设置如下: 导入UIKit 类PokemonCell:UICollectionViewCell { @IBOutlet弱var pokemonNameLabel:UILabel! @IBOutlet弱var pokemonImage:UIImageView! func updateWithImage(image:UIImage?){ 如果让imageToDisplay = image { pokemonImage.image = imageToDisplay }其他{ pokemonImage.image =无 } } 覆盖func awakeFromNib(){ super.awakeFromNib() updateWithImage(image:nil) } 覆盖func prepareForReuse(){ super.prepareForReuse() updateWithImage(image:nil) } } 连接您的插座,并将收集单元设置为PokemonCell。 在ViewController.swift文件中,设置数据源和集合视图的委托: collectionView.dataSource =自我 collectionView.delegate =自我 并设置您的DataSource和Delegate方法: 扩展ViewController:UICollectionViewDataSource { func numberOfSections(在collectionView:UICollectionView中)-> Int { 返回1 } func collectionView(_ collectionView:UICollectionView,numberOfItemsInSection部分:Int)-> Int { 返回myPokemon.count } […]