开发者

How to change Pagecontroller indicator color from default white?

http://apptech.next-munich.com/2010/04/customizing-uipagecontrols-looks.html

In the above url has some sample code for开发者_JAVA百科 customizing UIPageControl's Looks...

In my application i want to change the pagecontrol indicator(dot) color to some other color instead of default white...I'm following the code that are given in the above link.But,i'm having doubt.

NSString* imgActive = [[NSBundlemainBundle] pathForResource:IMG_PAGE_ACTIVE ofType:nil];

NSString* imgInactive = [[NSBundlemainBundle] pathForResource:IMG_PAGE_INACTIVE ofType:nil];

what should i give for pathForResource:-------------.and where should i add the images for active and inactive pages and how to retrieve the image into application.

please give me some ideas to do this...

Thanks in Advance


Just add the two images to your project resources. For example dot_active.png and dot_inactive.png.

NSString* imgActive = [[NSBundlemainBundle] pathForResource:@"dot_active" ofType:@"png"];
NSString* imgInactive = [[NSBundlemainBundle] pathForResource:@"dot_inactive" ofType:@"png"];

I use these two images:

How to change Pagecontroller indicator color from default white?

for the active dot

How to change Pagecontroller indicator color from default white?

for the inactive dots

EDIT

If you want to modify the size of the dots, maybe

for (NSUIntegersubviewIndex = 0; subviewIndex < [self.subviews count]; subviewIndex++) {
    UIImageView* subview = [self.subviews objectAtIndex:subviewIndex];
    if (subviewIndex == page) {
        [subview setImage:[UIImage imageWithContentsOfFile:imgActive]];
    } else {
        [subview setImage:[UIImage imageWithContentsOfFile:imgInactive]];
    }
    subview.frame = CGRectMake(/* position and dimensions you need */);
}

should do the trick.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜