0

画像を含む配列を作成し、animationImages を介してそれらをアニメーション化します。しかし今、私は配列インデックスから画像を表示したいです(カウントを使用してforループを作成し、カウントが1に等しい場合は配列からインデックス1の画像を表示します)、それらをアニメーション化します。1 から 100 までの数字を表示したいので必要です。私の数字が 11 に等しい場合は、数字の 1 を表示します (数字の 100 画像を作成しないようにするため)。どうすればできますか?ここに私の正しいコードがあります:

//Numbers images
UIImage *numberZero = [UIImage imageNamed:@"numberZero.png"];
UIImage *numberOne = [UIImage imageNamed:@"numberOne.png"];
UIImage *numberTwo = [UIImage imageNamed:@"numberTwo.png"];
UIImage *numberThree = [UIImage imageNamed:@"numberThree.png"];
UIImage *numberFour = [UIImage imageNamed:@"numberFour.png"];
UIImage *numberFive = [UIImage imageNamed:@"numberFive.png"];
UIImage *numberSix = [UIImage imageNamed:@"numberSix.png"];
UIImage *numberSeven = [UIImage imageNamed:@"numberSeven.png"];
UIImage *numberEight = [UIImage imageNamed:@"numberEight.png"];
UIImage *numberNine = [UIImage imageNamed:@"numberNine.png"];


//add numbers uiimage to numbersArray
numbersArray = [NSArray arrayWithObjects:numberZero, numberOne, numberTwo, numberThree, numberFour, numberFive, numberSix, numberSeven, numberEight, numberNine, nil];


UIImageView *imgview1 = [[UIImageView alloc] initWithFrame:CGRectMake(40, 90, 240, 240)];
imgview1.animationImages = numbersArray;
imgview1.animationDuration = 2;
imgview1.animationRepeatCount=1;
[imgview1 startAnimating];
[self.view addSubview:imgview1];

ありがとう!

4

2 に答える 2

1

あなたの質問は少しわかりませんが、画像を数字として使用して100(?)まで数えるアニメーションを作成しようとしていると思います。したがって、UIImageView各桁に1つずつ使用し、すべて同じアニメーション画像を使用して、相対的な長さでさまざまな場所をアニメーション化します。

float onesDurations = 2;
UIImageView *onesPlace = [[UIImageView alloc] init...]; 
onesPlace.animationImages = numbersArray;
onesPlace.animationDuration = onesDurations;

UIImageView *tensPlace = [[UIImageView alloc] init...]; 
tensPlace.animationImages = numbersArray;
tensPlace.animationDuration = 10*onesDurations; // ten times as slow as ones animation

UIImageView *hundredsPlace = [[UIImageView alloc] init...]; 
hundredsPlace.animationImages = numbersArray;
hundredsPlace.animationDuration = 100*onesDurations; // 100 times as slow animation

// add them all to the view
// start their animations
于 2012-06-28T19:02:38.037 に答える
0

カスタム フォントを使用して、画像の代わりにテキストを表示できます。ボーダーやアウトラインを追加したい場合は、もう少し作業が必要です。この質問は、テキストにアウトラインを追加する方法を説明しています。

お役に立てれば

于 2012-06-28T18:58:46.480 に答える