pagecontrol indicator custom image instead of Default
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:Expecte开发者_JS百科d ')' 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
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
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.
精彩评论