I have been working on a new feature for my Hourly News
iOS App that allows the addition of custom news sources to the app.
While testing out what happens when a customer adds dozens of feeds,
I noticed a problem with
… it doesn’t resize itself to fit within it’s bounds, and it draws outside of them! So, I started shopping around for an open-source replacement,
landing on SMPageControl for it’s customization level,
it’s stability and it’s longevity. Swapping the
UIPageControl for the
SMPageControl was pretty straightforward,
and it solved the problem of drawing outside of it’s bounds easily enough.
However, when there were more pages than room to fit them, the leading and trailing pages were cut off from the view.
SMPageControl allows for the customization of the indicator size and margin between them,
I wrote a little function that adjusted these values to ensure that all pages will fit and be displayed, within reason.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
Basically, it checks the calculated full width of the page control, and while that width is wider than the page control’s bounds, alternate a reduction of the indicator margin and diameter until it fits, or until it hits a reasonable minimum size. I call this in
willAnimateRotationToInterfaceOrientation and also whenever a source is added or removed from the app. Looks much better!
Lastly, I run a small software company called Urban Apps. It pays the bills so I can take the time to write helpful posts like this one. If you found this posting helpful at all, I would really appreciate it if you would check out my Apps on the iTunes App Store.