页面控制指示器自定义图像而不是默认图像

发布于 2024-10-10 19:08:58 字数 652 浏览 4 评论 0原文

如何更改分页颜色UIPageControl 的点?

在此链接中给出了示例代码。但它对我显示了 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 技术交流群。

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

发布评论

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

评论(2

╰ゝ天使的微笑 2024-10-17 19:08:59

我是编写您正在使用的示例代码的人。

我发现 VdesmedT 已经帮助您解决了遇到的语法问题。所以+1!

至于自定义点:提供的类不支持点的自定义图像。它只是使用 Core Graphics 绘制圆圈。圆圈的颜色是使用属性 dotColorCurrentPagedotColorOtherPage 配置的。

当前页面的默认颜色是带有黑点的灰点(因为这是我编写时所需要的)。

假设您想要当前页面使用红点而不是黑点,其他页面使用绿点。当您创建 PageControl 实例时,您只需分配如下属性:

pageControl.dotColorCurrentPage = [UIColor redColor];
pageControl.dotColorOtherPage = [UIColor greenColor];

... 假设您的实例变量名为 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 and dotColorOtherPage.

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:

pageControl.dotColorCurrentPage = [UIColor redColor];
pageControl.dotColorOtherPage = [UIColor greenColor];

... assuming your instance variable is called pageControl. Or use any of the other convenience/initialization methods for creating a UIColor that you like.

Hope this helps.

把梦留给海 2024-10-17 19:08:58

第一个错误可能是由于 self 没有引用视图(可能是视图控制器)。

第二个错误是因为在解析器到达协议定义时尚未定义 PageControl。

典型的代表类

@protocol MyProtocol;

@interface myClassWithDelegate
{
  id<MyProtocol> _delagate;
}

@end

@protocol MyProtocol
  -(void)MyClass:(MyClassWithDelegate*)c says(NSString*)message;
@end

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

@protocol MyProtocol;

@interface myClassWithDelegate
{
  id<MyProtocol> _delagate;
}

@end

@protocol MyProtocol
  -(void)MyClass:(MyClassWithDelegate*)c says(NSString*)message;
@end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文