PageOffice的自定义工具条按钮图标可以换成自己的吗
1个回答
展开全部
1.用户调用setCurrentPage:(NSInteger)currentPage时
所以重载这个函数便可拦截
2.点击圆点矩形区域时
这说明,我们可以通过重载setCurrentPage方法来进行拦截
源码如下:
1 MyPageControl.h:
2 #import Foundation.h>
3 @interface MyPageControl : UIPageControl
4 {
5 UIImage* activeImage;
6 UIImage* inactiveImage;
7 }
8 @end
1 MyPageControl.m:
2 #import "MyPageControl.h"
3 @implementation GrayPageControl
4
5 -(id) initWithFrame:(CGRect)frame
6 {
7 self = [super initWithFrame:frame];
8 activeImage = [[UIImage imageNamed:@"RedPoint.png"] retain];
9 inactiveImage = [[UIImage imageNamed:@"BluePoint.png"] retain];
10 return self;
11 }
12 -(void) updateDots
13 {
14 for (int i = 0; i < [self.subviews count]; i++)
15 {
16 UIImageView* dot = [self.subviews objectAtIndex:i];
17 if (i == self.currentPage) dot.image = activeImage;
18 else dot.image = inactiveImage;
19 }
20 }
21 -(void) setCurrentPage:(NSInteger)page
22 {
23 [super setCurrentPage:page];
24 [self updateDots];
25 }
26 @end
调用:
pageControl = [[GrayPageControl alloc] initWithFrame:CGRectMake(0.0, 460.0 - (96 + 48) / 2, 320.0, 48.0 /2)];
pageControl.userInteractionEnabled = NO;
就是这么简单
所以重载这个函数便可拦截
2.点击圆点矩形区域时
这说明,我们可以通过重载setCurrentPage方法来进行拦截
源码如下:
1 MyPageControl.h:
2 #import Foundation.h>
3 @interface MyPageControl : UIPageControl
4 {
5 UIImage* activeImage;
6 UIImage* inactiveImage;
7 }
8 @end
1 MyPageControl.m:
2 #import "MyPageControl.h"
3 @implementation GrayPageControl
4
5 -(id) initWithFrame:(CGRect)frame
6 {
7 self = [super initWithFrame:frame];
8 activeImage = [[UIImage imageNamed:@"RedPoint.png"] retain];
9 inactiveImage = [[UIImage imageNamed:@"BluePoint.png"] retain];
10 return self;
11 }
12 -(void) updateDots
13 {
14 for (int i = 0; i < [self.subviews count]; i++)
15 {
16 UIImageView* dot = [self.subviews objectAtIndex:i];
17 if (i == self.currentPage) dot.image = activeImage;
18 else dot.image = inactiveImage;
19 }
20 }
21 -(void) setCurrentPage:(NSInteger)page
22 {
23 [super setCurrentPage:page];
24 [self updateDots];
25 }
26 @end
调用:
pageControl = [[GrayPageControl alloc] initWithFrame:CGRectMake(0.0, 460.0 - (96 + 48) / 2, 320.0, 48.0 /2)];
pageControl.userInteractionEnabled = NO;
就是这么简单
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询