0

ラベルの移動と縮小のために基本的なアニメーションを動作させようとしています。ラベルのフレーム サイズを変更しなければ、アニメーションは正常に機能します。ただし、フレームを縮小する場合にのみ境界線を描画します。

ラベルの境界線だけが描かれているように、下の行で切り替えると、コメント行が正常に機能することがわかります。ここでの ToFrame は fromFrame より小さいです。

[UIView animateWithDuration:1.5 animations:
^{
    label = [[UILabel alloc] initWithFrame:fromFrame];
    [label setBackgroundColor:color];
    label.text = text;
    label.layer.cornerRadius = 10;
    label.layer.borderWidth = 4;
    [self.view addSubview:label];
    label.adjustsFontSizeToFitWidth = true;

    CGRect frame = label.frame;
    //frame.origin.y = self.view.frame.size.height;
    frame = toFrame;
    label.frame = frame;
}
completion:^ (BOOL finished)
{
    [label removeFromSuperview];
}

];
4

1 に答える 1

0

ラベル/ビューの画像をアニメーション化しました。これがコードです。おそらく誰かを助けるでしょう。ARCとQuartzが含まれていると仮定します。

- (void) animateFromFrame:(CGRect)fromFrame toFrame:(CGRect)toFrame andView:(UIView*)view
{
    UIGraphicsBeginImageContext(view.bounds.size);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    UIImageView* imageView = [[UIImageView alloc] initWithImage:image];

    imageView.frame = fromFrame;
    imageView.layer.cornerRadius = 10;
    imageView.layer.borderWidth = 4;
    [self.view addSubview:imageView];

    [UIView animateWithDuration:1.0 delay:0.25 options:nil animations: ^{ imageView.frame = toFrame; } completion:^ (BOOL finished) { [imageView removeFromSuperview]; } ];
}
于 2013-06-27T18:44:24.447 に答える