UIPage Control无法关注“可访问性”模式

时间:2016-10-26 07:38:15

标签: ios uipagecontrol uiaccessibility

我正在使用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];

0 个答案:

没有答案