MIBadgeButton-Swift
MIBadgeButton-Swift copied to clipboard
Fix to properly show badge when use with UIView from .xib + layout in programmatically way
I found a problem of badge doesn't show when I have a button which is MIBadgeButton
under a custom UIView
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 for swift3
thus master
branch later when this merge is accepted and merged.