簡體   English   中英

檢測相同的圖像名稱{iPhone SDK}

[英]Detect same images name {iPhone SDK}

我想創建圖像動畫,我現在有50張png格式的圖像,我想要設置圖像名稱...類似這樣的東西,但是不起作用!

我的圖像名稱是: iamge_0000 to image_0050

pasheAnimation.animationImages  = [NSArray arrayWithObjects:
                                  [UIImage imageNamed:@"pashe_0000.png"],nil];

    [pasheAnimation setAnimationRepeatCount:5];
    pasheAnimation.animationDuration = 4;
    [pasheAnimation startAnimating];

??!?!!?!?

傑森代碼[編輯]:

NSMutableArray* myImages = [[[NSMutableArray alloc] initWithCapacity:607] autorelease];
    for( int i = 1; i <= 607; i++ ) {
        [myImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"p%d.png",i]]];
    }

    butterflyView.animationImages = myImages;
    [butterflyView setAnimationRepeatCount:100];
    butterflyView.animationDuration = 0;
    [butterflyView startAnimating];
// There are actually 51 images in this series (0000-0050)     
NSMutableArray* myImages = [[[NSMutableArray alloc] initWithCapacity:51] autorelease];
for( int i = 0; i <= 50; i++ ) {
  [myImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"image_%04d.png", i]]?:[NSNull null]];
}

您實際上有51張圖像,從零到五十。

NSMutableArray *myImages = [NSMutableArray arrayWithCapacity:51];
for (NSUInteger idx = 0; idx <= 50; idx++) {
    NSString *filename = [NSString stringWithFormat:"image_%04d.png", idx];
    UIImage *image = [UIImage imageNamed:filename];
    if (image) {
        [myImages addObject:image];
    }
    else {
        NSLog(@"Could not add %@", filename); // could also throw exception, if you want
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM