ios - How to replace a number as an image in Xcode 5 -
i kinda new xcode , making program. when person gets score, output on screen. example, person got score of 132, show score "132", how replace numbers image instead of using font, numbers showing image. thinking if there anyway use output numbers picture, wouldn't put them in order or wouldn't work anyway. if can me, i'd appreciate it. thanks!
one = [uiimage imagenamed:@"1.png"]; //image number 1 2 = [uiimage imagenamed:@"2.png"]; //image number 2 3 = [uiimage imagenamed:@"3.png"]; //image number 3 nsstring *score = "132"; //this score user got if ([score rangeofstring:@"1"].location == nsfound) { imagescore = one; //if score contains one, image adds image 1 } if ([score rangeofstring:@"2"].location == nsfound) { imagescore += two; //if score contains two, image adds image 2 } if ([score rangeofstring:@"3"].location == nsfound) { imagescore +=three; //if score contains two, image adds image 3 } imageview.image = imagescore; //would change image images of score in order
here made array of uiimage score string:
edit: commented out array making parts , included imani's solution merge images together. clear?
-(void)calculatescore{ nsstring *score = @"132"; uiimage *scroreimage = [uiimage new]; // nsmutablearray *images = [[nsmutablearray alloc]initwithcapacity:score.length]; (int = 0; < score.length; i++) { // imagename @"1", @"3" , @"2" nsstring *imagename = [[score substringtoindex:i] substringtoindex:1]; // add extension imagename = [imagename stringbyappendingstring:@".png"]; uiimage *image = [uiimage imagenamed:imagename]; //[images addobject:image]; scroreimage = [self concateimageone:scroreimage withimagetwo:image] } } -(uiimage*)concateimageone:(uiimage*)image1 withimagetwo:(uiimage*)image2 { ///merge images }
Comments
Post a Comment