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
| import UIKit | |
| import SwiftUI | |
| /// Minimal reproducible example for a potential memory leak when replacing `tabs` with | |
| /// a new array that contains a tab with the same title/image/identifier. | |
| /// | |
| /// Repro steps: | |
| /// 1. Launch the app and open the Memory Graph (Product > Profile or Debug Memory Graph). | |
| /// 2. This controller first sets `tabs` to contain ViewControllerA. | |
| /// 3. It then immediately replaces `tabs` with a new array that contains ViewControllerB, |
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
| 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 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
| import SwiftUI | |
| struct ContentView: View { | |
| var body: some View { | |
| SquareLayout { | |
| Button { | |
| } label: { | |
| Color.green | |
| .frame(width: 320, height: 640) |
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
| 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 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
| protocol FooRepository { | |
| func foo() -> String | |
| } | |
| final class FooClient { | |
| static let shared = FooClient() | |
| private init() {} | |
| } |
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
| // 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 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
| // 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 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
| 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