【问题标题】:Animation of UILabel's frame (and other views' frames) in UITableViewCellUITableViewCell 中 UILabel 的框架(和其他视图的框架)的动画
【发布时间】:2012-11-09 22:59:06
【问题描述】:

请帮忙。试图让帧位置的动画在 UITableViewCell 内工作,特别是我试图移动默认的 UILabel (cell.textLabel)。但是,无论我使用什么技术,我都无法移动单元格内的任何视图。颜色和 alpha 动画的工作原理如下面的代码所示。

提前为帮助喝彩。

安迪

这是我正在使用的代码:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0 && indexPath.row == 0) {

        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

        CGRect textLabelFrame = cell.textLabel.frame;
        textLabelFrame.origin.x = -textLabelFrame.size.width;

       [UIView animateWithDuration:0.5
            delay:0.0
            options:UIViewAnimationCurveEaseOut
            animations:^{
                cell.textLabel.frame = textLabelFrame; // THIS DOESN'T WORK - HELP!
                cell.imageView.frame = CGRectOffset(cell.imageView.frame,0,0); // EVEN TRYING TO MOVE IMAGEVIEW DOESN'T WORK
                cell.textLabel.alpha = 0; // This animates
                cell.imageView.backgroundColor = [UIColor redColor]; // This animates
            }
            completion:^(BOOL finished){
                NSLog(@"Done!");
        }];
    }
}

【问题讨论】:

  • 尝试创建自定义 uitableview 单元并使用它。

标签: ios uitableview quartz-core


【解决方案1】:

我认为不可能在标准单元格中重新定位默认标签或图像视图。如果你想这样做,你应该将你自己的子视图添加到单元格的 contentView 中,并用它们做动画。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-15
    • 2010-12-11
    • 1970-01-01
    相关资源
    最近更新 更多