剛剛找到答案。希望這可以幫助別人:
- (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;
}
FYI有對蘋果的網站上視差預覽:https://developer.apple.com/tvos/download/有很多在YouTube上的如何使用這一點。 – Jacksonkr
我們創建了控件和擴展,可以用來輕鬆添加視差效果到任何UIView github.com/PGSSoft/ParallaxView –