【发布时间】:2019-08-25 07:01:27
【问题描述】:
我有一个类似UICollectionViewCell 的问题,我必须同时闪烁多个单元格。但是现在如果一个单元格闪烁然后如果我同时选择另一个单元格而不是最后一个项目停止闪烁并且该项目开始闪烁。我想闪烁标签文本。
有两个问题:
- 如果我向上或向下滚动,我想闪烁它不应该影响或更新单元格。它应该会一直闪烁。
- 多个单元格闪烁
请我已经花了很多时间,但我不知道如何解决。
现在尝试: 我现在已经试过了:
它解决了我的错误单元格闪烁问题。但是现在多个单元格一起闪烁我不知道如何解决这个问题
cell.pricePlate.alpha = 0;
[UIView animateWithDuration:1.0f delay:0.1f options:UIViewAnimationOptionCurveLinear animations:^{
[UIView setAnimationRepeatCount:3.0];
cell.pricePlate.alpha = 1;
cell.pricePlate.textColor = RED;
} completion:^(BOOL finished) {
NSLog(@"cell12 -> %ld %ld",(long)cell.tag, (long)indexPath.row);
cell.pricePlate.alpha = 1;
if(self.cellIdToBlink <= 0)
{
cell.pricePlate.textColor = BLACK;
}
else
{
cell.pricePlate.textColor = GREEN;
}
}];
之前尝试过: 我以前也试过这个:
这是在单元格类中。像打电话一样
[cell blinking];
这个问题是,如果我向下滚动并出现一个闪烁,它会闪烁并更新错误的单元格。也消除闪烁。我认为这是因为在执行选择器时它无法找到正确的单元格。所以它随机闪烁。
int counter = 1;
for (int i = 0; i<3 ; i++)
{
if(i == 2)
{
[self performSelector:@selector(animateColor1234:) withObject:color afterDelay:1.5*counter];
++counter;
}
else{
[self performSelector:@selector(animateColor1234:) withObject:BLACK afterDelay:1.5*counter];
++counter;
}
}
-(void) animateColor1234:(UIColor *)color {
[UIView transitionWithView:_pricePlate duration:1 options: UIViewAnimationOptionTransitionCrossDissolve animations:^{
_pricePlate.textColor = RED;
}
completion:^(BOOL finished){
if (finished){
[UIView transitionWithView:_pricePlate duration:1 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
_pricePlate.textColor = BLACK;
}
completion:^(BOOL done){
if (done){
// Do some program upkeep logic
_pricePlate.textColor = color;
}
}];
}
else
{
_pricePlate.textColor = color;
}
}];
}
我测试的最后一个动画:
CABASE 动画:
我不知道如何用它为文本设置动画。它仅用于背景和前景
这是如何让单元格出队
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
CustomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CarCellID" forIndexPath:indexPath];
if(thisItemToBlink)
{
cell.pricePlate.alpha = 0;
[UIView animateWithDuration:1.0f delay:0.1f options:UIViewAnimationOptionCurveLinear animations:^{
[UIView setAnimationRepeatCount:3.0];
cell.pricePlate.alpha = 1;
cell.pricePlate.textColor = RED;
} completion:^(BOOL finished) {
NSLog(@"cell12 -> %ld %ld",(long)cell.tag, (long)indexPath.row);
cell.pricePlate.alpha = 1;
if(self.cellIdToBlink <= 0)
{
cell.pricePlate.textColor = BLACK;
}
else
{
cell.pricePlate.textColor = GREEN;
}
}];
}
}
else
{
//just change text as not selected item
}
return cell;
}
【问题讨论】:
-
请任何帮助将不胜感激......
标签: ios objective-c swift uicollectionview uicollectionviewcell