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
import Accelerate | |
/// This object provides easy color sampling of the `capturedImage` property of an ARFrame. | |
/// | |
/// - Warning: This class is NOT thread safe. The `rawRGBBuffer` property is shared between instances | |
/// and will cause a lot of headaches if 2 instances try to simultaneously access it. | |
/// If you need multi-threading, make the shared buffer an instance property instead. | |
/// Just remember to release it when you're done with it. | |
class CapturedImageSampler { |
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
extension UIScrollView { | |
fileprivate var layoutGuideID: String { #function } | |
public var headerLayoutGuide: UILayoutGuide { | |
if let layoutGuide = addedHeaderLayoutGuide() { | |
return layoutGuide | |
} | |
// workaround: UIScrollView can't add new layoutGuide directly. | |
let anchorView = UIView() | |
addSubview(anchorView) |
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
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
SquareLayout { | |
Button { | |
} label: { | |
Color.green | |
.frame(width: 320, height: 640) |
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
extension UIWindowScene { | |
func scrollToTop() { | |
guard let window = keyWindow else { return } | |
var nextResponder: UIResponder? = window.hitTest(window.center, with: UIEvent()) | |
while let responder = nextResponder?.next { | |
if let scrollView = responder as? UIScrollView { | |
scrollView.setContentOffset(.zero, animated: true) | |
} | |
nextResponder = responder | |
} |
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
protocol FooRepository { | |
func foo() -> String | |
} | |
final class FooClient { | |
static let shared = FooClient() | |
private init() {} | |
} |
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
// swift-tools-version:5.5 | |
// The swift-tools-version declares the minimum version of Swift required to build this package. | |
import PackageDescription | |
let package = Package( | |
name: "AppPackage", | |
platforms: [.iOS(.v15)], | |
products: [ | |
.library(name: "AppModule", targets: ["AppModule", "DebugMenuModule"]), |
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
// swift-tools-version: 5.5 | |
// WARNING: | |
// This file is automatically generated. | |
// Do not edit it by hand because the contents will be replaced. | |
import PackageDescription | |
import AppleProductTypes | |
let package = Package( |
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
if (arFaceManager.subsystem is ARKitFaceSubsystem subsystem) { | |
using(var blendShapes = subsystem.GetBlendShapeCoefficients(face.trackableId, Allocator.Temp)) { | |
view.SetBlendShapes(blendShapes); | |
} | |
} | |
private void SetBlendShapes(NativeArray < ARKitBlendShapeCoefficient > blendShapes) { | |
foreach(var blendShape in blendShapes) { | |
float x = 0.0 f; | |
float fixedCoefficient = 0.0 f; |
NewerOlder