iOS Pagecontrol control does not have a point color settings, the beginning of their own do not believe, a color property modification, Apple will not so pit it, do a lot of things you will slowly find that Apple is so resistant, a lot of functions to improve themselves.
Originally found some information on the internet is to Pagecontrol point as a uiimage, I use the xcode5.2 debugging found that Pagecontrol child control is not Uiimageview, the point is a uiviwe, by modifying the View Layer control shape. When you know this, you have the idea.
Ideas:
1, write an inheritance Uipagecontrol class
2, rewrite the setcurrentpage method of Uipagecontrol
3, modify the color of the current point
Code
#import <UIKit/UIKit.h>
@interface Commonpagecontrol:uipagecontrol
{
UIImage *activeimage;
UIImage *inactiveimage;
}
@end #import "CommonPageControl.h"
@implementation Commonpagecontrol
-(ID) initWithFrame: (CGRect) frame
{
self = [super Initwithframe:frame];
if (self) {
Initialization code
}
return self;
}
-(void) updatedots{
for (int i=0;i<[self.subviews count];i++) {
if ([(UIView *) [Self.subviews objectatindex:i] Iskindofclass:[uiview class]) {//current Pagecontrol control dot is a view
UIView *dot=[self.subviews OBJECTATINDEX:I];
if (i==self.currentpage) {
Dot.backgroundcolor=[uicolor Whitecolor];
}
else{
Dot.backgroundcolor = [Uicolor colorwithred:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.1];
}
}
}
}
overriding base class methods
-(void) Setcurrentpage: (Nsinteger) currentpage{
[Super Setcurrentpage:currentpage];
[Self updatedots];
}
@end call: CGRect rect;
rect.origin.x = myscrollview.frame.origin.x;
RECT.ORIGIN.Y = self.frame.size.height-20;
Rect.size.width = MyScrollView.frame.size.width;
Rect.size.height = 20; Mypagecontrol = [[Commonpagecontrol alloc] initwithframe:rect];
Mypagecontrol.userinteractionenabled=no;