Created
September 14, 2021 20:00
-
-
Save hectorddmx/a68718e119250a9a52804259b0cb099b to your computer and use it in GitHub Desktop.
CustomTabBar.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomeTabBar: UITabBar { | |
// Other code here... | |
override func draw(_ rect: CGRect) { | |
// self.paintHitBox() | |
self.addShape() | |
} | |
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { | |
let normalBox = super.point(inside: point, with: event) | |
let normalBoxText = normalBox ? "🟢YES" : "🔴NO" | |
os_log("normalBox: %{public}@, from point: %{public}@", log: OSLog.loginFlow, type: .info, normalBoxText, point.debugDescription) | |
/// last time I set this offset to -20 with iPhones with Home Bar Indicator or | |
/// -10 if they have home button. | |
if point.y >= tabBarHeightOffset { | |
os_log("🟢 point(inside point: CGPoint, with event: UIEvent?) 😸😸", log: OSLog.loginFlow, type: .info) | |
return true | |
} | |
return normalBox | |
} | |
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { | |
guard let items = items, items.count > 0 else { | |
return super.hitTest(point, with: event) | |
} | |
let insideMiddleButton = middleRect.contains(point) | |
if insideMiddleButton { | |
prominentButtonCallback?() | |
} | |
return super.hitTest(point, with: event) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment