This file contains hidden or 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
struct ViewControllerLifecycleHandler: UIViewControllerRepresentable { | |
func makeCoordinator() -> ViewControllerLifecycleHandler.Coordinator { | |
Coordinator(onDidAppear: onDidAppear) | |
} | |
let onDidAppear: () -> Void | |
func makeUIViewController(context: UIViewControllerRepresentableContext<ViewControllerLifecycleHandler>) -> UIViewController { | |
context.coordinator | |
} |
This file contains hidden or 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
func imageWithGradient(startColor: UIColor, endColor: UIColor, size: CGSize, horizontally: Bool = true) -> UIImage? { | |
let gradientLayer = CAGradientLayer() | |
gradientLayer.frame = CGRect(x: 0, y: 0, width: size.width, height: size.height) | |
gradientLayer.colors = [startColor.cgColor, endColor.cgColor] | |
if horizontally { | |
gradientLayer.startPoint = CGPoint(x: 0.0, y: 0.5) | |
gradientLayer.endPoint = CGPoint(x: 1.0, y: 0.5) | |
} else { | |
gradientLayer.startPoint = CGPoint(x: 0.5, y: 0.0) |
This file contains hidden or 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
/* | |
Usage: | |
let urlString = "https://example.com/?foo=bar¶m2=none&__is_cowboy=false" | |
let url = URL(string: urlString) | |
let urlWithoutParameters = url?.removeParameters(with: ["param2", "__is_cowboy"]) | |
print(urlWithoutParameters!) | |
Result: https://example.com/?foo=bar is printed | |
*/ |