पर UICollectionViewCell को एनिमेट करें, जब उपयोगकर्ता किसी सेल पर टैप करता है तो UICollectionViewCell
पर कुछ एनीमेशन शुरू करना चाहता हूं। मेरा विचार didSelectItemAtIndexPath
में संबंधित सेल का चयन करना था और एक एनीमेशन ट्रिगर करना था। हालांकि, यह काम नहीं करता:टैप
- (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];
}
];
}
वास्तव में, एनीमेशन शुरू होता है और एक ही समय में समाप्त हो जाती है (हालांकि animateWithDuration
5 के लिए सेट है)। अगला प्रयास एनीमेशन छोड़ था और केवल उदाहरण के लिए एक अलग बॉर्डर शैली सेट: (? शायद इसलिए क्योंकि मैं मैन्युअल रूप से सेल पुनः बनाने का है)
- (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
ओएमजी, इसके लिए thx। – sabiland