janselv / fave-button

FaveButton is an iOS cute animated like button written in Swift.
MIT License
1.51k stars 201 forks source link

UIBarButtonItem Support iOS 11 and higher. #50

Open kmishukov opened 5 years ago

kmishukov commented 5 years ago

I have added constraints that fix bug, when FaveButton is untouchable when it is added to navigation bar as UIBarButtonItem(customView: FaveButton), this problem occurred on iOS 11 and higher.

class ViewController: UIViewController, FaveButtonDelegate {

    let myButton = FaveButton(frame: CGRect(x: 0, y: 0, width: 24, height: 24),
                              faveIconNormal: UIImage(named: "star"))

    override func viewDidLoad() {
        super.viewDidLoad()
        myButton.delegate = self
        navigationItem.rightBarButtonItem = UIBarButtonItem(customView: myButton)
    }

    func faveButton(_ faveButton: FaveButton, didSelected selected: Bool) {
        print("Button pressed!")
    }
}

ezgif-1-f46038bad9d0

joshhopkins commented 5 years ago

Can this be merged please?