【发布时间】:2016-03-21 05:33:20
【问题描述】:
我正在尝试向我的 UIBarButtonItem 添加一个徽章,为此我找到了这个 github:
但我不知道如何使用它。
这是我制作自定义 UIBarButtonItem 的代码:
let shopingCartBTN = UIButton(type: UIButtonType.Custom)
shopingCartBTN.setImage(UIImage(named: "shopingCarBarIcon"), forState: UIControlState.Normal)
shopingCartBTN.imageView?.image = UIImage(named: "shopingCarBarIcon")
shopingCartBTN.frame = CGRectMake(0, 0, 60, 30)//Just increase the width of button
shopingCartBTN.setTitle("5", forState: .Normal)
shopingCartBTN.addTarget(self, action: "", forControlEvents: UIControlEvents.TouchUpInside)
let customBarItem = UIBarButtonItem(customView: shopingCartBTN)
self.navigationItem.leftBarButtonItem = customBarItem;
如何使用 MIBadgeButton-Swift 为我的 UIBarButtonItem 制作徽章?
【问题讨论】:
标签: ios swift uinavigationcontroller uibarbuttonitem