0

アニメーション画像を UILabel 背景として設定しようとしています。私のラベルはポイントから移動します (x=0 y260 から x=480 y=260) アニメーション中に UIImage を追加したいです。だから私はこのように試します

UIImageView *myimg=[[UIImageView alloc]init];
        myimg.animationImages =[NSArray arrayWithObjects:   
                                [UIImage imageNamed:@"1ANI.png"],
                                [UIImage imageNamed:@"2ANI.png"],
                                [UIImage imageNamed:@"3ANI.png"],nil];

        myimg.animationDuration = 1.5;
        myimg.animationRepeatCount = 0;
        [myimg startAnimating]; 
        [lbl1 addSubview:myimg];
        [myimg release];

このように単一のUIImageでUILabelの背景を設定します

UIImage *image=[UIImage imageNamed:@"1ANI.png"];
            lbl2.backgroundColor = [UIColor colorWithPatternImage:image]; 

単一の画像コードは機能しますが、アニメーション画像で実装しようとすると(上記のコードショーのように)、機能しませんアニメーション画像を UILabel Background.Thanx として設定する方法を教えてくれますか?

4

3 に答える 3

1

これを試して

UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 21)];
[label setText:@"asfsdf" ];
[label setBackgroundColor:[UIColor clearColor]];

UIImageView *imagView=[[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 100, 21)];
imagView.animationImages =[NSArray arrayWithObjects:
                        [UIImage imageNamed:@"1ANI.png"],
                        [UIImage imageNamed:@"2ANI.png"],
                        [UIImage imageNamed:@"3ANI.png"],nil];

imagView.animationDuration = 1.5;
imagView.animationRepeatCount = 0;
[imagView startAnimating];
[self.view addSubview:imagView];
[self.view addSubview:label];
于 2012-10-17T14:28:00.277 に答える
0

まず第一に、UIImageViewをサブビューとしてラベル付けするために追加しないでください[lbl1 addSubview:myimg];

最初にimageviewを追加してから、それにuilabelを追加します。ラベルは透明になり、uiimageviewにフロートします。

[imageView setuserinteractionEnabled:YES];uiimageviewも必要になる場合があります 。

于 2012-10-17T13:29:54.107 に答える
0

これはiOS 7で動作します

[myLabel setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"panel_dev_header"]]];

于 2014-01-12T23:42:35.977 に答える