0

i created an array that contain images, i animate them via animationImages. but now i want to view image from the array index(i want to create a for loop with count, and if my count is equal to 1 so it will view the image at index 1 from the array) and animate them. i need it becuase i want to view number from 1 to 100 and if my number is equal to 11 then i will show number 1 twich(to avoid from creating 100 image of numbers). how can i do it? here is my correct code:

//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];

thanks!

cnaaniomer
  • 97
  • 1
  • 3
  • 10
  • how important is it that you want the images? if you can find a font that looks similar then you can just use a regular label and update the text. – KDaker Jun 28 '12 at 18:50
  • i know but i want to create a double border to the label's text, if it is possible it will avoid me from a lot of work... is it possible?? – cnaaniomer Jun 28 '12 at 18:55
  • I'm not very familiar with it, but there's a framework called Core Text that you can check out here: . Core Text is an advanced, low-level technology for laying out text and handling fonts. Maybe you could use that for the double border – pasawaya Jun 28 '12 at 19:11

2 Answers2

1

I'm a little unsure of your question, but I gather you're trying to animate counting to 100(?) using your images as the digits. Thus, use one UIImageView for each digit, all with the same animations images, and animate the different places at relative durations:

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
thelaws
  • 7,991
  • 6
  • 35
  • 54
0

You could display text instead of images with a custom font. If you want to add a border or outline, then you will have to do abit more work. this question explains how you can add an outline to your text.

hope this helps

Community
  • 1
  • 1
KDaker
  • 5,899
  • 5
  • 31
  • 44