gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 20:47:21 25 4
gpt4 key购买 nike

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

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

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

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

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

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

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

提前致谢

最佳答案

只需将这两个图像添加到您的项目资源中即可。例如 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 */);
}

应该可以解决问题。

关于iphone - 如何更改 Pagecontroller 指示器颜色默认的白色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4625419/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com