//
//  GMBaseNavigationButton.swift
//  Pods
//
//  Created by wangyang on 2016/10/21.
//
//

import Foundation
public class GMBaseNavigationButton: UIButton {

    // 常常导航栏上的切图资源都比较小，所以需要代码来扩大其响应范围
    var adaptiveHotAreaWidth: CGFloat = 0
    var adaptiveHotAreaHeight: CGFloat = 0

    override public func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
        let widthDelta = max(adaptiveHotAreaWidth - bounds.size.width, 0)
        let heightDelta = max(adaptiveHotAreaHeight - bounds.size.height, 0)
        bounds = bounds.insetBy(dx: -0.5 * widthDelta, dy: -0.5 * heightDelta)
        return bounds.contains(point)
    }
}
