Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added support for square thumbs

  • Loading branch information...
commit 74e2310a59b712d7e8bf48932dd539deec0c57b8 1 parent 2476af5
@honcheng authored
View
3  StyledPageControlDemo/PageControlDemo/StyledPageControl.h
@@ -42,7 +42,8 @@ typedef enum
PageControlStylePressed1 = 2,
PageControlStylePressed2 = 3,
PageControlStyleWithPageNumber = 4,
- PageControlStyleThumb = 5
+ PageControlStyleThumb = 5,
+ PageControlStyleStrokedSquare = 6,
} PageControlStyle;
@interface StyledPageControl : UIControl
View
20 StyledPageControlDemo/PageControlDemo/StyledPageControl.m
@@ -119,7 +119,7 @@ - (void)drawRect:(CGRect)rect
if (self.coreSelectedColor) coreSelectedColor = self.coreSelectedColor;
else
{
- if (self.pageControlStyle==PageControlStyleStrokedCircle || self.pageControlStyle==PageControlStyleWithPageNumber)
+ if (self.pageControlStyle==PageControlStyleStrokedSquare || self.pageControlStyle==PageControlStyleStrokedCircle || self.pageControlStyle==PageControlStyleWithPageNumber)
{
coreSelectedColor = COLOR_GRAYISHBLUE;
}
@@ -146,7 +146,7 @@ - (void)drawRect:(CGRect)rect
if (self.strokeSelectedColor) strokeSelectedColor = self.strokeSelectedColor;
else
{
- if (self.pageControlStyle==PageControlStyleStrokedCircle || self.pageControlStyle==PageControlStyleWithPageNumber)
+ if (self.pageControlStyle==PageControlStyleStrokedSquare || self.pageControlStyle==PageControlStyleStrokedCircle || self.pageControlStyle==PageControlStyleWithPageNumber)
{
strokeSelectedColor = COLOR_GRAYISHBLUE;
}
@@ -247,6 +247,22 @@ - (void)drawRect:(CGRect)rect
CGContextStrokeEllipseInRect(myContext, CGRectMake(x,(self.frame.size.height-diameter)/2,diameter,diameter));
}
}
+ else if (self.pageControlStyle==PageControlStyleStrokedSquare)
+ {
+ CGContextSetLineWidth(myContext, self.strokeWidth);
+ if (i==self.currentPage)
+ {
+ CGContextSetFillColorWithColor(myContext, [coreSelectedColor CGColor]);
+ CGContextFillRect(myContext, CGRectMake(x,(self.frame.size.height-diameter)/2,diameter,diameter));
+ CGContextSetStrokeColorWithColor(myContext, [strokeSelectedColor CGColor]);
+ CGContextStrokeRect(myContext, CGRectMake(x,(self.frame.size.height-diameter)/2,diameter,diameter));
+ }
+ else
+ {
+ CGContextSetStrokeColorWithColor(myContext, [strokeNormalColor CGColor]);
+ CGContextStrokeRect(myContext, CGRectMake(x,(self.frame.size.height-diameter)/2,diameter,diameter));
+ }
+ }
else if (self.pageControlStyle==PageControlStyleWithPageNumber)
{
CGContextSetLineWidth(myContext, self.strokeWidth);

0 comments on commit 74e2310

Please sign in to comment.
Something went wrong with that request. Please try again.