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

Badge displaying behind button content #11

Open
ryryan opened this issue Jul 8, 2016 · 1 comment
Open

Badge displaying behind button content #11

ryryan opened this issue Jul 8, 2016 · 1 comment

Comments

@ryryan
Copy link

ryryan commented Jul 8, 2016

Using the below code to display a UIBarButtonItem with a Font Awesome icon. The Badge displays behind the shopping cart.

Any help would be appreciated.

let button = MIBadgeButton(type: .Custom)
button.badgeString = String(qty)
button.frame = CGRectMake(0, 0, 55, 40)
button.badgeEdgeInsets = UIEdgeInsetsMake(15, 0, 0, 10)
button.titleLabel?.font = UIFont.fontAwesomeOfSize(30)
button.setTitle(String.fontAwesomeIconWithName(FontAwesome.ShoppingCart), forState: .Normal)
button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
button.badgeBackgroundColor = UIColor(red: 147/255, green: 149/255, blue: 151/255, alpha: 1.0)
button.setTitleColor(UIColor(red: 147/255, green: 149/255, blue: 151/255, alpha: 0.6), forState: .Highlighted)
button.addTarget(self, action: #selector(DryCleaning.backToServices), forControlEvents: UIControlEvents.TouchUpInside)
let barButton = UIBarButtonItem(customView: button)
self.navigationItem.rightBarButtonItem = barButton
@tomneo2004
Copy link
Contributor

tomneo2004 commented Oct 12, 2016

What is UIFont.fontAwesomeOfSize(30)? I don't get fontAwesome..

Below I change your code and it can display badge without behind anything.

let button = MIBadgeButton(type:.custom) button.badgeString = String("12") button.frame = CGRect(x: 0, y: 0, width: 50, height: 60) button.badgeEdgeInsets = UIEdgeInsetsMake(15, 0, 0, 10) //button.titleLabel?.font = UIFont.fontAwesomeOfSize(30) button.setTitle("asdf", for: .normal) button.setTitleColor(UIColor.red, for: .normal) button.badgeBackgroundColor = UIColor(red: 147/255, green: 149/255, blue: 151/255, alpha: 1.0) button.setTitleColor(UIColor(red: 147/255, green: 149/255, blue: 151/255, alpha: 0.6), for: .highlighted) //button.addTarget(self, action: #selector(DryCleaning.backToServices), forControlEvents: UIControlEvents.TouchUpInside) let barButton = UIBarButtonItem(customView: button) self.navigationItem.rightBarButtonItem = barButton self.title = "nav controller"

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

No branches or pull requests

2 participants