gpt4 book ai didi

ios - UICollectionviewcell翻转效果

转载 作者:行者123 更新时间:2023-11-28 21:38:32 25 4
gpt4 key购买 nike

我正在使 Collection View 单元格翻转并提供有关单元格的信息。

Storyboard:

-Collectionviewcell
-- View1 (tag 100)
-- View2 (tag 200)

didSelectItemAtIndexPath 上的代码。

UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
UIView *firstView = (UIView *)[cell viewWithTag:200];
UIView *secondView = (UIView *)[cell viewWithTag:100];
NSString *indexValue = [flipIndex objectAtIndex:indexPath.row];
if (![indexValue isEqualToString:@"1"])
{
[UIView animateWithDuration:1.0 animations:^{
NSLog(@"ANIMATION STARTED");
[UIView transitionFromView:secondView
toView:firstView
duration:2.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
[firstView setHidden:NO];
[secondView setHidden:YES];
}];
}completion:^(BOOL finished) {
NSLog(@"ANIMATION COMPLETED");
}];

[flipIndex removeObjectAtIndex:indexPath.row];
[flipIndex insertObject:@"1" atIndex:indexPath.row];
} else
{
[UIView animateWithDuration:1.0 animations:^{
NSLog(@"ANIMATION STARTED");
[UIView transitionFromView:firstView
toView:secondView
duration:2.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
[secondView setHidden:NO];
[firstView setHidden:YES];
}];
}completion:^(BOOL finished) {
NSLog(@"ANIMATION COMPLETED");
}];

我在这里面临的问题是,第一次点击时 View 从 View 1 翻转到 View 2。第二次点击 View 2 时, View 1 为空白,因为它为零。

感谢帮助。

最佳答案

试试这个:

[UIView transitionWithView:cell.contentView
duration:1
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
if (cell.isFirstView) {
cell.isFirstView = NO;

firstView.hidden = NO;
secondView.hidden=YES;
} else {
cell.isFirstView = YES;

firstView.hidden = YES;
secondView.hidden = NO;
}
} completion:nil];

关于ios - UICollectionviewcell翻转效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32993463/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com