如何更改 Pagecontroller 指示器颜色默认的白色?

发布于 2024-10-11 04:33:15 字数 650 浏览 3 评论 0原文

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

在上面的网址中,有一些用于自定义 UIPageControl 外观的示例代码...

在我的应用程序中,我想将 pagecontrol 指示器(点)颜色更改为其他颜色,而不是默认的白色。 ..我正在遵循上面链接中给出的代码。但是,我有疑问。

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

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

我应该为 pathForResource 提供什么:-------------。我应该在哪里添加活动页面和非活动页面的图像以及如何将图像检索到应用程序中。

请给我一些想法来做到这一点...

提前致谢

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

In the above url has some sample code for 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

盗梦空间 2024-10-18 04:33:15

只需将这两个图像添加到您的项目资源中即可。
例如 dot_active.pngdot_inactive.png

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

我使用这两个图像:

Active image 作为活动点

Inactive image 用于非活动点

编辑

如果您想修改点的大小,也许

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 */);
}

应该这样做。

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:

Active image for the active dot

Inactive image 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文