Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
Fixed possible division by zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvervuurt committed Jul 7, 2015
1 parent 6f3f4b6 commit 96c5ab7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions JVSUIButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ class JVSUIButton: UIButton {
return super.pointInside(point, withEvent: event)
} else {
let initialBounds: CGRect = self.bounds
let additionalHitTargetWidth: CGFloat = self.bounds.width < self.minimumHitTargetWidth ? self.minimumHitTargetWidth - self.bounds.width : 0
let additionalHitTargetHeight: CGFloat = self.bounds.height < self.minimumHitTargetHeight ? self.minimumHitTargetHeight - self.bounds.height : 0
let extendedBounds: CGRect = CGRectInset(self.bounds, -(additionalHitTargetWidth / 2), -(additionalHitTargetHeight / 2))

let additionalHitTargetWidth: CGFloat = self.bounds.width < self.minimumHitTargetWidth ? (self.minimumHitTargetWidth - self.bounds.width) / 2 : 0
let additionalHitTargetHeight: CGFloat = self.bounds.height < self.minimumHitTargetHeight ? (self.minimumHitTargetHeight - self.bounds.height) / 2 : 0

let extendedBounds: CGRect = CGRectInset(self.bounds, -additionalHitTargetWidth, -additionalHitTargetHeight)

return CGRectContainsPoint(extendedBounds, point)
}
Expand Down

0 comments on commit 96c5ab7

Please sign in to comment.