ユーザーがセルをタップすると、UICollectionViewCell
でアニメーションを開始したいと思います。私の考えは、didSelectItemAtIndexPath
の対応するセルを選択し、アニメーションをトリガーすることでした。しかし、これは動作しない:(animateWithDuration
は5に設定されているが)タップでアニメーションUICollectionViewCell
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
// animate the cell user tapped on
ProductCollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ProductReuseID" forIndexPath:indexPath];
[UIView animateWithDuration:5.0
delay:0
options:(UIViewAnimationOptionAllowUserInteraction)
animations:^{
NSLog(@"animation start");
[cell.layer setBackgroundColor:[UIColor colorWithRed: 180.0/255.0 green: 238.0/255.0 blue:180.0/255.0 alpha: 1.0].CGColor];
}
completion:^(BOOL finished){
NSLog(@"animation end");
[cell.layer setBackgroundColor:[UIColor whiteColor].CGColor];
}
];
}
実際には、アニメーションの開始と同時に終了します。次の試みは、アニメーションをスキップすることだったし、単にインスタンスに異なる境界線スタイルを設定します(?私は手動でセルを再描画する必要があるからでしょう)
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
// animate the cell user tapped on
ProductCollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ProductReuseID" forIndexPath:indexPath];
[cell.layer setBorderWidth:5.0f];
}
しかし、これは何も変わりません。
ユーザーがタップしたときにUICollectionViewCellをアニメーション化する方法はありますか?
敬具、 クリスチャン
ありがとうございました!それは問題を解決した... – itsame69
OMG、これのためのthx。 – sabiland