No Description

LargerButton.swift 1.1KB

    // // LargerButton.swift // PaiAi // // Created by mac on 16/7/21. // Copyright © 2016年 FFIB. All rights reserved. // import UIKit class LargerButton: UIButton { @IBInspectable var expandLeft: CGFloat = 0 @IBInspectable var expandRight: CGFloat = 0 @IBInspectable var expandTop: CGFloat = 0 @IBInspectable var expandBottom: CGFloat = 0 var expandEdge: UIEdgeInsets { set { expandLeft = newValue.left expandRight = newValue.right expandTop = newValue.top expandBottom = newValue.bottom } get { return UIEdgeInsets(top: expandTop, left: expandLeft, bottom: expandBottom, right: expandRight) } } override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { let largerRect = CGRect(x: -expandLeft, y: -expandTop, width: bounds.width + expandLeft + expandRight, height: bounds.height + expandTop + expandBottom) if largerRect.contains(point) { return self } else { return nil } } }