Extract out TouchTransparentStackView
This commit is contained in:
parent
ff502a4868
commit
dc6a86f846
|
@ -26,22 +26,6 @@ final class MediaPreviewViewController: UIViewController, NeedsDependency {
|
||||||
let pagingViewController = MediaPreviewPagingViewController()
|
let pagingViewController = MediaPreviewPagingViewController()
|
||||||
|
|
||||||
let topToolbar: UIStackView = {
|
let topToolbar: UIStackView = {
|
||||||
class TouchTransparentStackView: UIStackView {
|
|
||||||
// allow button hit boxes to grow outside of this view’s bounds
|
|
||||||
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
|
||||||
subviews.contains { $0.point(inside: $0.convert(point, from: self), with: event) }
|
|
||||||
}
|
|
||||||
|
|
||||||
// allow taps on blank areas to pass through
|
|
||||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
|
||||||
let view = super.hitTest(point, with: event)
|
|
||||||
if view == self {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return view
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let stackView = TouchTransparentStackView()
|
let stackView = TouchTransparentStackView()
|
||||||
stackView.axis = .horizontal
|
stackView.axis = .horizontal
|
||||||
stackView.distribution = .equalSpacing
|
stackView.distribution = .equalSpacing
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
//
|
||||||
|
// TouchTransparentStackView.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Jed Fox on 2022-12-21.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
/// A subclass of `UIStackView` that allows touches that aren’t captured by any
|
||||||
|
/// of its subviews to pass through to views beneath this view in the Z-order.
|
||||||
|
public class TouchTransparentStackView: UIStackView {
|
||||||
|
// allow subview hit boxes to grow outside of this view’s bounds
|
||||||
|
public override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
||||||
|
subviews.contains { $0.point(inside: $0.convert(point, from: self), with: event) }
|
||||||
|
}
|
||||||
|
|
||||||
|
// allow taps on blank areas to pass through
|
||||||
|
public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||||
|
let view = super.hitTest(point, with: event)
|
||||||
|
if view == self {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue