ios - UICollectionView: 1 row horizontal scrolling (right to left) with custom animation for new cell coming from right -
- i have 1 row collections view images
i scroll images right left
i make animation each cell coming right (ala google+)
this animation based on alpha or frame location
how implement ?
this may not want in animations here i've done in uicollectionviewcell subclass. fade in cell while frame shrinks down appropriate size. call setphoto
method within collectionview: cellforitematindexpath:
.
@implementation historycollectionviewcell - (void)setphoto:(photo*)photo { if(_photo != photo) { _photo = photo; } // set animations here self.photoqueue.alpha = 0.0f; self.cellcontainerview.alpha = 0.0f; cgrect currentframe = self.cellcontainerview.frame; cgfloat width = currentframe.size.width + 20; cgfloat height = currentframe.size.height + 20; cgfloat originx = currentframe.origin.x - 10; cgfloat originy = currentframe.origin.y - 10; cgrect newframe = cgrectmake(originx, originy, width, height); self.cellcontainerview.frame = newframe; dispatch_queue_t photoqueue = dispatch_queue_create("com.jeremyfox.snapto.photoqueue", null); dispatch_async(photoqueue, ^{ __block uiimage* image = nil; if (_photo) { image = [photo getimageatpath:_photo.thumbnail]; } dispatch_async(dispatch_get_main_queue(), ^{ if (image) { self.imageview.image = image; // perform animations here [uiview animatewithduration:0.3f animations:^{ self.cellcontainerview.alpha = 1.0f; self.cellcontainerview.frame = currentframe; }]; } }); }); }
Comments
Post a Comment