A while back we introduced SMPageControl, our drop in replacement for UIPageControl with a slew of extra bells and whistles. It was surprisingly well received, and is by far the most popular bit of open source code we’ve released to date. (Thanks for starring the repo on GitHub!)
Unfortunately, it seems that deeming it a “drop in replacement” wasn’t 100% accurate; while SMPageControl provided a pixel perfect representation of UIPageControl, it lacked UIAccessibility support all together. I hate to admit it, but until recently I haven’t paid much attention to accessibility in the iOS apps I’ve worked on. That has changed – for a variety of reasons that I plan to cover in a future blog post – and SMPageControl now really is a drop in replacement, providing the exact same UIAccessibility behaviors as UIPageControl.
But Wait, There’s More!
In sticking with the theme of being UIPageControl’s Fancy One-Upping Cousin, SMPageControl extends UIPageControl’s accessibility functions by letting you give each page its own name. The default behavior is to set the accessibility value to
"page [current page + 1] of [number of pages]". e.g.
"page 1 of 10". If a page has been named, the provided name is prepended to the default accessibility value. e.g
"Search - page 1 of 10". This is extremely useful when using per page indicator images, where one or more page is likely to have a specific usage that is identifiable to the user.
SMPageControl *pageControl = [[SMPageControl alloc] init]; [pageControl setImage:[UIImage imageNamed:@"searchDot"] forPage:0]; [pageControl setCurrentImage:[UIImage imageNamed:@"currentSearchDot"] forPage:0]; [pageControl setImage:[UIImage imageNamed:@"appleDot"] forPage:1]; [pageControl setCurrentImage:[UIImage imageNamed:@"currentAppleDot"] forPage:1]; [pageControl setName:@"Search" forPage:0]; [pageControl setName:@"Apple" forPage:1];
Version 1.0 and CocoaPods
With the addition of accessibility support, I feel comfortable calling SMPageControl a 1.0; bugs may still surface, and features may be added, but the goal of creating a fully featured page control has been achieved. Having reached this point, I’ve created a 1.0 version tag in the git repo and added it to CocoaPods.
As always, feedback is welcome. We accept pull requests for features and bug fixes at the GitHub repo, so if you’d like to contribute, by all means, please do.Tweet