1

我有一个字典数组,每个字典都有一些文本,一个 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];
                    }];
            }];
    }
} 
4

1 回答 1

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
于 2013-11-20T14:42:05.707 回答