Bubble Speech Animation在iOS6中运行良好,但在iOS7中运行不正常

时间:2013-09-26 14:26:58

标签: animation ios6 uitextview ios7

我有一个字典数组,每个字典都有一些文本,CGRect是一个延迟。我设置了一个带背景的UITextView,然后在预览完成后开始播放下一个动画的数组。一切在iOS6上运行正常,但在iOS7上如果在动画期间闪烁,然后在消失的延迟期间消失。

我在viewDidAppear

中调用它
-(void)speachInit
{
    // Make an image with the background of the bubble, use CapInsets to preserve the edges of the image
    UIImage *bubble = [[UIImage imageNamed:@"bubble_bottom.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(12, 12, 12, 12)];

    // Add the image to an image view
    UIImageView *bubbleImage = [[UIImageView alloc] initWithImage:bubble];
    bubbleImage.frame = CGRectZero;
    [bubbleImage setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];

    // Setup a text View with whatever is needed
    UITextView *bubbletext = [[UITextView alloc]initWithFrame:CGRectZero];
    bubbletext.textColor = [UIColor lightGrayColor];
    bubbletext.backgroundColor = [UIColor clearColor];
    bubbletext.font = [UIFont fontWithName:@"Helvetica Neue" size:13];
    [bubbletext setEditable:NO];
    [bubbletext setTextAlignment:NSTextAlignmentJustified];

    [bubbletext setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];

    // Add the image to the textView and then push to back
    [bubbletext addSubview:bubbleImage];
    [bubbletext sendSubviewToBack:bubbleImage];

    // Add the text (including the image) to the main view
    [self.view addSubview:bubbletext];

    // Start the animation
    [self speachStart:bubbletext];
}

然后在这个底部我开始动画

-(void)speachStart:(UITextView *)speachView
{
    // Test we have reached the end of the array
    if([speaches count] > speachCount)
    {
        // Start an animation from 0,0 to the place specified in the array
        [UIView animateWithDuration:0.3
                          delay:0.3
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^(void)
            {
                speachView.text = [speaches objectAtIndex:speachCount][@"speachText"];
                speachView.frame = [[speaches objectAtIndex:speachCount][@"speachShape"]CGRectValue];

            } completion:^(BOOL finished)
            {
                // Once completed add new animation to reduce to 0,0
                [UIView animateWithDuration:0.3
                               delay:[[speaches objectAtIndex:speachCount][@"speachDuration"]floatValue]
                             options:UIViewAnimationOptionCurveEaseIn
                          animations:^(void)
                    {
                        speachView.frame = CGRectZero;
                    } completion:^(BOOL finished)
                    {
                        // Once this has completed increment the array pointer
                        speachCount++;
                        // And start over with next item in array
                        [self speachStart:speachView];
                    }];
            }];
    }
} 

1 个答案:

答案 0 :(得分:1)

最后,我删除了动画中的Frame更改,并使用了仍然看起来不错的Alpha更改。

因此,例如第一部分就像这样开始,然后完成动画才回到Alpha 0。

    speachView.alpha = 0.0f;
    speachView.text = [speaches objectAtIndex:speachCount][@"speachText"];
    speachView.frame = [[speaches objectAtIndex:speachCount][@"speachShape"]CGRectValue];

    [UIView animateWithDuration:0.3
                          delay:0.3
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^(void)
            {
//                    speachView.text = [speaches objectAtIndex:speachCount][@"speachText"];
//                    speachView.frame = [[speaches objectAtIndex:speachCount][@"speachShape"]CGRectValue];
                speachView.alpha = 1.0f;
            } completion:^(BOOL finished)
            {........ and so on