MIBadgeButton-Swift icon indicating copy to clipboard operation
MIBadgeButton-Swift copied to clipboard

Fix to properly show badge when use with UIView from .xib + layout in programmatically way

Open haxpor opened this issue 7 years ago • 0 comments

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 screen shot 2017-04-25 at 4 54 03 pm

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.

haxpor avatar Apr 25 '17 09:04 haxpor