Fix to properly show badge when use with UIView from .xib + layout in programmatically way #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found a problem of badge doesn't show when I have a button which is
MIBadgeButton
under a customUIView
from.xib
, and when create an instance from that view, use programmatic way in creating constraints dynamically.Thus this merge fixed this problem, and still respect the original way of positioning badge via modifying
frame
. It will check in view hierarchy first whether it needs to apply such solution or not.The solution creates constraints dynamically to position badge properly and accordingly, and also use calculated values from original method too for performance.
Demo sample (also included in this merge) will be like this now
The first row shows when use
.xib
and dynamic constraints.The second row shows original and normal approach.
Edit:
This is against
swift2
. I can contribute forswift3
thusmaster
branch later when this merge is accepted and merged.