カスタムラベルを持つカスタムUICollectionViewCell
があります。ユーザーがセルをタップすると、アニメーションにカスタムラベルの外観が表示されます。私は参照変数を保持し、collectionView.reloadData()
を呼び出すことを試みましたが、私のcellForItemAtIndexPath
では更新がアニメーション化されません。むしろ、それは即座に起こります。ラベルのフォントとサイズの変更をどのようにアニメーション化できますか?選択時にUICollectionViewCellラベルをアニメーション化する
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
self.flatPicker.reloadData()
self.variable = indexPath.row
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! UICollectionViewCell
cell.label.text = self.array[indexPath.row]
if indexPath.row == variable {
UIView.animateWithDuration(2, animations: {
cell.label.font = UIFont.boldSystemFontOfSize(12)
cell.label.textColor = UIColor.darkGrayColor()
})
} else {
UIView.animateWithDuration(2, animations: {
cell.label.font = UIFont.systemFontOfSize(11)
cell.label.textColor = UIColor.lightGrayColor()
})
}
return cell
}
リロードしない... didSelectItemAtIndexPathで参照を取得し、そのセルだけをアニメーション化します。 私はよく分かりませんが、メソッドcellForRowAtIndexPathがあると思います。その後、didSelectItemAtIndexPathの参照を取得してアニメーション化することができます。 – UlyssesR