pageControl改变点点颜色

在控件本身的属性上是确实不能的。

要自己实现些东西。

网上有人写的例子:

GrayPageControl.h:

#import <Foundation/Foundation.h>

@interface GrayPageControl : UIPageControl

{

    UIImage* activeImage;

    UIImage* inactiveImage;

}

@end


GrayPageControl.m:

#import "GrayPageControl.h"

@implementation GrayPageControl

//-(id) initWithCoder:(NSCoder *)aDecoder

//{

//    self = [super initWithCoder:aDecoder];

//

//    activeImage = [[UIImage imageNamed:@"RedPoint.png"] retain];

//    inactiveImage = [[UIImage imageNamed:@"BluePoint.png"] retain];

//

//    return self;

//}

-(id) initWithFrame:(CGRect)frame

{

self = [super initWithFrame:frame];

activeImage = [[UIImage imageNamed:@"RedPoint.png"] retain];

    inactiveImage = [[UIImage imageNamed:@"BluePoint.png"] retain];

    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


试用该类的方法是:

pageControl = [[GrayPageControl alloc] initWithFrame:CGRectMake(0.0, 460.0 - (96 + 48) / 2, 320.0, 48.0 / 2)];

pageControl.userInteractionEnabled = NO;


上述代码转载自:http://stackoverflow.com/questions/3409319/is-there-a-way-to-change-page-indicator-dots-color


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值