开发者

How to adapt this iPhone paging control to images instead of colors

+ (UIColor *)pageControlColorWithIndex:(NSUInteger)index {
    if (__pageControlColorList == nil) {
        __pageControlColorList = [[NSArray alloc] initWithObjects:[UIColor grayColor], [UIColor greenColor], [UIColor magentaColor],
                                  [UIColor blueColor], [UIColor orangeColor], [UIColor brownColor], [UIColor redColor], nil];
    }
    return [__pageControlColorList objectAtIndex:index % [__pageControlColorList count]];
}

in this above code,i want to repalce the colors display in each page by changing it to uiimages,,i want to load images insted of colors ,,what can i do to so开发者_开发问答lve this problem,,please help

thankzz


Use as below for images

+ (UIImage *)pageControlColorWithIndex:(NSUInteger)index {
    if (__pageControlColorList == nil) {
        __pageControlColorList = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"imageforPage1.png"], [UIImage imageNamed:@"imageforPage2.png"],[UIImage imageNamed:@"imageforPage3.png"], [UIImage imageNamed:@"imageforPage4.png"], [UIImage imageNamed:@"imageforPage5.png"], [UIImage imageNamed:@"imageforPage6.png"], [UIImage imageNamed:@"imageforPage7.png"], nil];
    }
     //Check whether the **index** supply by you fall within the limit of Image array.
    if(index <  [__pageControlColorList count])
    {
       return [__pageControlColorList objectAtIndex:index % [__pageControlColorList count]];
    }
    else 
    {
       //If the **index** doesn't fall within the limit the Image array then return a default image
       return [UIImage imageNamed:@"defaultImageforPages.png"];
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜