Fix to properly show badge when use with UIView from .xib + layout in programmatically way#24
Open
haxpor wants to merge 2 commits intomustafaibrahim989:swift2from
Open
Fix to properly show badge when use with UIView from .xib + layout in programmatically way#24haxpor wants to merge 2 commits intomustafaibrahim989:swift2from
haxpor wants to merge 2 commits intomustafaibrahim989:swift2from
Conversation
constraint - note that buttons in demo constructed to work with UIImageView. UIButton for logic, and UIImageView to represent button image i.e. facebook or twitter logo - background color of CustomView and UIView that holds UIButton and UIImageView has transparent color thus badges from normal buttons can be properly showed In short, it will work like before and no need to worry about different usage. What added is taking care and handle for the case if user construct UI element with .xib and in programmatically way with dynamic constraint. See the demo code for example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
MIBadgeButtonunder a customUIViewfrom.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
.xiband dynamic constraints.The second row shows original and normal approach.
Edit:
This is against
swift2. I can contribute forswift3thusmasterbranch later when this merge is accepted and merged.