3

UILabelを使用してのみ幅が増減するように、の幅をアニメーション化するにはどうすればよいですか。UIView animateWithDuration

あなたの助けに感謝します(この時点で私はそうしようとしていたのでとてもイライラしていますが、それはうまくいきません)

4

5 に答える 5

2

UILabelUIViewアニメーションブロック内のフレームを設定できます。このようなもの:

CGRect originalFrame = self.address.frame;

[UIView animateWithDuration:0.3
                 animations:^{
    self.myLabel.frame = CGRectMake(0, 0, 100, 100);
}
                 completion:^(BOOL finished) {
                     // use similar UIView animation to resize back to original
                 }];

明らかに、フィードするサイズはアプリによって異なり、コンテンツに基づいて計算される場合があります。

于 2012-07-10T08:17:15.773 に答える
0

以下のようなアニメーションでフレーム幅を増減してみてください

    // original label frame CGRectMake( 0,0, 100,60 );
    [UIView beginAnimations: @"moveLogo" context: nil]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationCurve: UIViewAnimationCurveLinear];
    [UIView setAnimationRepeatAutoreverses:YES];
    [UIView setAnimationRepeatCount:4];
    //increasing frame width
    label.frame =  CGRectMake( 0,0, 400,60 );   
    [UIView commitAnimations];
于 2012-07-10T08:51:54.690 に答える
0

これを試して

 [UIView animateWithDuration:0.6 animations:^(void)
  {
     self.label.bounds = CGRectMake(100, 100, 200, 100); 

 }completion:^(BOOL finished) {

     [UIView animateWithDuration:0.6 animations:^(void)
     {
         self.label.bounds = CGRectMake(100, 100, 100, 100); 
     }];

 }];
于 2012-07-10T08:57:32.613 に答える
0

ついにiOS5.0のブロックでこのようになりました

        [UIView animateWithDuration:2. delay:0 options:UIViewAnimationOptionAutoreverse|UIViewAnimationOptionBeginFromCurrentState  animations:^{
            [self.messageLabel setFrame:CGRectMake(90, 0, labelSize.width, 90)];

        } completion:^(BOOL finished) {

        }];
于 2012-07-10T09:57:04.050 に答える
0

私はこのようにそれを行うことができました。自己とは、ラベルを追加するビューを指します。initで、幅が1ピクセルのラベルを追加します。次に、以下を使用します。UIViewAnimationOptionBeginFromCurrentStateを使用すると、ドアのように開くことができます。

    [UIView animateWithDuration:1. delay:0 options:UIViewAnimationOptionBeginFromCurrentState  animations:^{
        [self setFrame:CGRectMake(self.frame.origin.x-labelSize.width-PADDING, self.frame.origin.y, self.frame.size.width+labelSize.width+PADDING, self.frame.size.height)];
        [self.messageLabel setFrame:CGRectMake(95, 10, labelSize.width, labelSize.height)];
        self.messageLabel.alpha = 1; 
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:1. delay:2. options:0  animations:^{
            self.messageLabel.alpha = 0;  
        } completion:^(BOOL finished) {
            [UIView animateWithDuration:1. delay:0. options:0  animations:^{
                [self setFrame:CGRectMake(self.frame.origin.x+labelSize.width+PADDING, self.frame.origin.y, self.frame.size.width-labelSize.width-PADDING, self.frame.size.height)];
            } completion:^(BOOL finished) {
            }];
        }];
    }];
于 2012-07-11T07:44:27.497 に答える