Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for AutoLayout matching UIPageControl #17

Merged

Conversation

idpaterson
Copy link
Contributor

In order to work properly in AutoLayout, SMPageControl needed an implementation of intrinsicContentSize, a straightforward adaptation of sizeThatFits:. Otherwise the height will be ambiguous, requiring the app to set a height constraint. However, doing so doesn't jive well with hiding the page control.

To match the behavior of UIPageControl, the intrinsic height is set to zero when the control should be hidden due to the number of pages (UIPageControl is always hidden in this way for zero pages, otherwise depends on hidesForSinglePage). This is convenient in the case where a constraint has been added, for example, between the top of the page control and the bottom of some other view. When the page control is hidden, the other view can adjust to fill the now vacant space.

As a minor convenience, the MIN_HEIGHT constant has been updated to a minHeight property. This allows easier customization of the control in situations where it is merely for display purposes and not receiving user interaction. In my case, the page control is being set to userInteractionEnabled = NO so that the minimum height can be reduced. Similarly if the page control is adjacent to another control like a tab bar, the height may be increased to enlarge the touch target.

…ntrol. If set to less than the indicatorDiameter, the value will be set to the indicatorDiameter.
…ng it to 36.0f without regard to the style. While both styles use the same default height this may be useful to other styles in the future.
…is zero when the control is hidden as a result of having only one or zero pages.
jerryhjones added a commit that referenced this pull request Dec 9, 2013
Added support for AutoLayout matching UIPageControl
@jerryhjones jerryhjones merged commit d27f33a into Spaceman-Labs:master Dec 9, 2013
@jerryhjones
Copy link
Member

Hey @idpaterson, sorry for taking so long to merge this. This is a great PR, I had seen people complaining about SMPageControl not really working with auto layout, but hadn't spent the time to figure out why. Thanks!

@idpaterson
Copy link
Contributor Author

No problem, thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants