页面控制指示器自定义图像而不是默认图像
在此链接中给出了示例代码。但它对我显示了 3 个错误...
第一个错误:
Line:CGRect currentBounds = self.bounds;
错误:请求非结构或联合中的成员“边界”
方法:-(void)drawRect:
第二个错误:touchesBegan 方法中同一行出现相同错误。
第三个错误:@protocol PageControlDelegate
@可选
- (void)pageControlPageDidChange:(PageControl *)pageControl;
@end
Error:Expected ')' before 'PageControl' 。这是我发生的三个错误...请帮我解决这个问题..
我想更改 pagecontrol 指示符(点)颜色...
谢谢 &问候, 雷努加
How can i change the color of pagination dots of UIPageControl?
In this link the sample code is given.But it shows 3 errors for me...
1'st ERROR:
Line:CGRect currentBounds = self.bounds;
Error:requst for member 'bounds' in something not a structure or union
Method:-(void)drawRect:
2nd Err: same error with same line in touchesBegan method.
3rd Err:@protocol PageControlDelegate
@optional
- (void)pageControlPageDidChange:(PageControl *)pageControl;
@end
Error:Expected ')' before 'PageControl' .These are the three errors occurs for me...Please help me out to solve this..
I want to change the pagecontrol indicator(dot) color...
Thanks & Regards,
Renuga
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我是编写您正在使用的示例代码的人。
我发现 VdesmedT 已经帮助您解决了遇到的语法问题。所以+1!
至于自定义点:提供的类不支持点的自定义图像。它只是使用 Core Graphics 绘制圆圈。圆圈的颜色是使用属性
dotColorCurrentPage
和dotColorOtherPage
配置的。当前页面的默认颜色是带有黑点的灰点(因为这是我编写时所需要的)。
假设您想要当前页面使用红点而不是黑点,其他页面使用绿点。当您创建
PageControl
实例时,您只需分配如下属性:... 假设您的实例变量名为
pageControl
。或者使用任何其他便利/初始化方法来创建您喜欢的UIColor
。希望这有帮助。
I'm the one who wrote the sample code you are using.
I see that VdesmedT has already helped you on the syntax issues you were having. So +1 for that!
As for customizing the dots: The class as provided does not support custom images for the dots. It just draws circles using Core Graphics. The color of the circles is configured using the properties
dotColorCurrentPage
anddotColorOtherPage
.The default colors are grey dots with a black dot for the current page (because that is what I needed when I wrote it).
Let's say you want a red dot instead of a black dot for the current page and green dots for the other pages. When you create your
PageControl
instance you simply assign the properties like this:... assuming your instance variable is called
pageControl
. Or use any of the other convenience/initialization methods for creating aUIColor
that you like.Hope this helps.
第一个错误可能是由于
self
没有引用视图(可能是视图控制器)。第二个错误是因为在解析器到达协议定义时尚未定义 PageControl。
典型的代表类
first error is probably due to the fact that
self
does not refer to a view (a view controller maybe)Second error is because PageControl is not yet defined by the time the parser come to your protocol definition.
Typical Class with delegate