UIPageControl设置

//创建与设置

UIScrollView *merchantHeaderMenuScrollView = [[UIScrollView alloc]init];

//注意!!!就是在tableView里,加入滚动框,要监听该滚动框的滚动,一定要写代理赋值!!

merchantHeaderMenuScrollView.delegate = self;

merchantHeaderMenuScrollView.backgroundColor = [UIColor whiteColor];

[self.merchantHeaderView addSubview:merchantHeaderMenuScrollView];

self.merchantHeaderMenuScrollView = merchantHeaderMenuScrollView;

UIPageControl *merchantHeaderMenuPageControl = [[UIPageControl alloc]init];

// 设置UIPageControl的圆点的颜色

merchantHeaderMenuPageControl.pageIndicatorTintColor = UIColorFromRGBA(200, 200, 200, 0.6);

// 设置UIPageControl的高亮圆点的颜色

merchantHeaderMenuPageControl.currentPageIndicatorTintColor = kMainColorOfApp;

//设置UIPageControl不容许用户交互

merchantHeaderMenuPageControl.userInteractionEnabled = NO;

[self.merchantHeaderView addSubview:merchantHeaderMenuPageControl];

merchantHeaderMenuPageControl.backgroundColor = [UIColor whiteColor];

//设置frame

self.merchantHeaderMenuPageControl.frame = CGRectMake(0, CGRectGetMaxY(self.merchantHeaderMenuScrollView.frame),self.merchantHeaderView.width,37);

//监听滚动框滚动

#pragma mark - scrollViewDelegate

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{

if (![scrollView isKindOfClass:[self.tableView class]]) {

self.merchantHeaderMenuPageControl.currentPage = (int)self.merchantHeaderMenuScrollView.contentOffset.x / self.merchantHeaderMenuScrollView.width;

}

}

你可能感兴趣的:(UIPageControl设置)