我正在使用UIPageController
来切换页面。但有些原因是它无法专注于Accessibility
模式下的页面指示器。以下是我实施的方式:
CGRect rect = [self.view bounds];
rect.size.height+=37;
[[self.pageController view] setFrame:rect];
NSArray *subviews = self.pageController.view.subviews;
for (int i=0; i<[subviews count]; i++) {
if ([[subviews objectAtIndex:i] isKindOfClass:[UIPageControl class]])
{
//self.pageControl = (UIPageControl *)[subviews objectAtIndex:i];
UIView *pv = [subviews objectAtIndex:i];
CGRect frame = pv.frame;
[pv removeFromSuperview];
[self.pageControl setFrame:frame];
self.pageControl.isAccessibilityElement = YES;
self.pageControl.accessibilityTraits = UIAccessibilityTraitAdjustable;
self.pageControl.accessibilityHint = @"Page Indicator";
//[self.pageController.view addSubview:self.pageControl];
}
}
UIView *pageControlBaseView = [[UIView alloc] initWithFrame:CGRectMake(0, [Utilities is_iPad] ? PAGECONTROL_POSITION_IPAD: PAGECONTROL_POSITION_IPHONE, PAGECONTROL_BASEVIEW_WIDTH, PAGECONTROL_BASEVIEW_HEIGHT)];
[pageControlBaseView addSubview:self.pageControl];
pageControlBaseView.isAccessibilityElement = YES;
self.pageControl.pageIndicatorTintColor = [UIColor grayColor];
self.pageControl.currentPageIndicatorTintColor = [UIColor whiteColor];
[self.view addSubview:pageControlBaseView];