Hello,
This code is useful for creating your custom page control having different color.
#import <Foundation/Foundation.h>
@interface GrayPageControl : UIPageControl
{
UIImage* activeImage;
UIImage* inactiveImage;
}
@property(nonatomic, retain) UIImage* activeImage;
@property(nonatomic, retain) UIImage* inactiveImage;
@end
#import "GrayPageControl.h"
@implementation GrayPageControl
@synthesize activeImage;
@synthesize inactiveImage;
-(id) initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
activeImage = [UIImage imageNamed:@"active_page_image.png"];
inactiveImage = [UIImage imageNamed:@"inactive_page_image.png"];
return self;
}
-(void)updateDots
{
for (int i = 0; i < [self.subviews count]; i++)
{
UIImageView* dot = [self.subviews objectAtIndex:i];
if (i == self.currentPage)
dot.image = activeImage;
else
dot.image = inactiveImage;
}
}
-(void)setCurrentPage:(NSInteger)page
{
[super setCurrentPage:page];
[self updateDots];
}
@end
After creating these two files in your project you have to declare:
IBOutlet UIPageControl *nameObject;
in which you want to use this control and then you have to set his class in .XIB file as "GrayPageControl".
If any one has query then place you it over here.
Thanks and Regards,
Nilesh Prajapati
This code is useful for creating your custom page control having different color.
#import <Foundation/Foundation.h>
@interface GrayPageControl : UIPageControl
{
UIImage* activeImage;
UIImage* inactiveImage;
}
@property(nonatomic, retain) UIImage* activeImage;
@property(nonatomic, retain) UIImage* inactiveImage;
@end
#import "GrayPageControl.h"
@implementation GrayPageControl
@synthesize activeImage;
@synthesize inactiveImage;
-(id) initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
activeImage = [UIImage imageNamed:@"active_page_image.png"];
inactiveImage = [UIImage imageNamed:@"inactive_page_image.png"];
return self;
}
-(void)updateDots
{
for (int i = 0; i < [self.subviews count]; i++)
{
UIImageView* dot = [self.subviews objectAtIndex:i];
if (i == self.currentPage)
dot.image = activeImage;
else
dot.image = inactiveImage;
}
}
-(void)setCurrentPage:(NSInteger)page
{
[super setCurrentPage:page];
[self updateDots];
}
@end
After creating these two files in your project you have to declare:
IBOutlet UIPageControl *nameObject;
in which you want to use this control and then you have to set his class in .XIB file as "GrayPageControl".
If any one has query then place you it over here.
Thanks and Regards,
Nilesh Prajapati