Post

Replies

Boosts

Views

Activity

Reply to iOS 18 hit testing functionality differs from iOS 17
I just ran into this issue and this works pretty well for me: final class PassthroughWindow: UIWindow { override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { guard let hitView = super.hitTest(point, with: event), let rootView = rootViewController?.view else { return nil } if #available(iOS 18, *) { for subview in rootView.subviews.reversed() { let convertedPoint = subview.convert(point, from: rootView) if subview.hitTest(convertedPoint, with: event) != nil { return hitView } } return nil } else { return hitView == rootView ? nil : hitView } } }
Oct ’24
Reply to Command SwiftCompile failed with a nonzero exit code (syntax is correct)
Fix your switch statement to have the . syntax. Here is what your code should look like, I also fixed your toWidth typo. enum Constraints<T> { case setTop(to: T, constant: CGFloat = 0) case setBottom(to: T, constant: CGFloat = 0) case setLeading(to: T, constant: CGFloat = 0) case setTrailing(to: T, constant: CGFloat = 0) case toBottom(of: T, constant: CGFloat = 0) case toTop(of: T, constant: CGFloat = 0) case toLeading(of: T, constant: CGFloat = 0) case toTrailing(of: T, constant: CGFloat = 0) case toHeight(of: T, multiplier: CGFloat = 1) case toWidth(of: T, multiplier: CGFloat = 1) } extension UIView { func applyConstraints(_ constraints: Constraints<UIView>...) { self.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate( constraints.map { switch $0 { case .setTop(to: let to, constant: let constant): return self.topAnchor.constraint(equalTo: to.topAnchor, constant: constant) case .setBottom(to: let to, constant: let constant): return self.bottomAnchor.constraint(equalTo: to.bottomAnchor, constant: constant) case .setLeading(to: let to, constant: let constant): return self.leadingAnchor.constraint(equalTo: to.leadingAnchor, constant: constant) case .setTrailing(to: let to, constant: let constant): return self.trailingAnchor.constraint(equalTo: to.trailingAnchor, constant: constant) case .toBottom(of: let of, constant: let constant): return self.topAnchor.constraint(equalTo: of.bottomAnchor, constant: constant) case .toTop(of: let of, constant: let constant): return self.bottomAnchor.constraint(equalTo: of.topAnchor, constant: constant) case .toLeading(of: let of, constant: let constant): return self.trailingAnchor.constraint(equalTo: of.leadingAnchor, constant: constant) case .toTrailing(of: let of, constant: let constant): return self.leadingAnchor.constraint(equalTo: of.trailingAnchor, constant: constant) case .toHeight(of: let of, multiplier: let multiplier): return self.heightAnchor.constraint(equalTo: of.heightAnchor, multiplier: multiplier) case .toWidth(of: let of, multiplier: let multiplier): return self.widthAnchor.constraint(equalTo: of.widthAnchor, multiplier: multiplier) } } ) } }
May ’23