Ich möchte eine Animation auf einem UICollectionViewCell
starten, wenn der Benutzer auf eine Zelle klopft. Meine Idee war, die entsprechende Zelle in didSelectItemAtIndexPath
auszuwählen und eine Animation auszulösen. Allerdings funktioniert das nicht:Animiere UICollectionViewCell auf Tap
- (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];
}
];
}
Eigentlich sind die Animation beginnt und gleichzeitig endet (obwohl animateWithDuration
auf 5 gesetzt ist). Nächster Versuch war die Animation überspringen und einfach zum Beispiel eine andere Grenze Stil festgelegt: (wahrscheinlich, weil ich die Zelle manuell neu zu zeichnen haben)
- (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];
}
Doch dies ändert nichts.
Haben Sie Ideen, wie Sie eine UICollectionViewCell animieren können, wenn der Benutzer darauf klickt?
Mit freundlichen Grüßen, Christian
Vielen Dank! Das hat das Problem gelöst ... – itsame69
OMG, danke dafür. – sabiland