Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tvOS: Creating parallax effect on UICollectionViewCell

I'm using iOS 9 Storyboards to create a tvOS app.

The app has a UICollectionView. I've defined an Apple TV image stack that contains a Front, Middle and Back asset in my Assets.xcassets collection.

When a user highlights a UICollectionViewCell, I'd like to have a have a 'highlight' effect similar to what the app icon has, where a user can 'circle' their finger on the Siri remote to expose the parallax effect and shine.

Does anyone have any experience with this?

like image 283
dpigera Avatar asked Sep 26 '15 00:09

dpigera


1 Answers

Just found an answer. Hope this helps someone else:

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"CameraCell" forIndexPath:indexPath];

    UIImage *image = [_cameras objectAtIndex:indexPath.row];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    imageView.userInteractionEnabled = YES;
    imageView.adjustsImageWhenAncestorFocused = YES;
    imageView.frame = CGRectMake(0, 0, 853, 560);
    [cell addSubview:imageView];

    return cell;
}
like image 194
dpigera Avatar answered Sep 21 '22 09:09

dpigera