Skip to content

Instantly share code, notes, and snippets.

View noppefoxwolf's full-sized avatar
🦊
きつねかわいい!!!

noppe noppefoxwolf

🦊
きつねかわいい!!!
View GitHub Profile
@noppefoxwolf
noppefoxwolf / UIScrollView+headerLayoutGuide.swift
Last active November 3, 2023 13:37
UIScrollView+headerLayoutGuide
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)
import SwiftUI
struct ContentView: View {
var body: some View {
SquareLayout {
Button {
} label: {
Color.green
.frame(width: 320, height: 640)
@noppefoxwolf
noppefoxwolf / ScrollToTop.swift
Created February 9, 2023 23:22
simulate statusbar action.
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
}
import Foundation
import SFSafeSymbols
import UIKit
@resultBuilder
public struct MenuBuilder {
public static func buildBlock(_ components: UIMenuElement...) -> [UIMenuElement] {
components
}
}
@noppefoxwolf
noppefoxwolf / main.swift
Created April 12, 2022 15:22
Case: using type erasure
protocol FooRepository {
func foo() -> String
}
final class FooClient {
static let shared = FooClient()
private init() {}
}
@noppefoxwolf
noppefoxwolf / Package.swift
Last active January 4, 2022 13:51
PreviewApp Package.swift
// 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(
@noppefoxwolf
noppefoxwolf / Package.swift
Created January 4, 2022 13:48
EditormodeのPackage.swift
// 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"]),
//
// TCAModule.swift
//
//
// Created Tomoya Hirano on 2021/07/04.
// Copyright © 2021 ___ORGANIZATIONNAME___. All rights reserved.
//
//
import SwiftUI
@noppefoxwolf
noppefoxwolf / perfectsync.cs
Created June 21, 2021 08:20
perfectsync.cs
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;
//
// ViewController.swift
// a
//
// Created by Tomoya Hirano on 2021/06/15.
//
import UIKit
class ViewController: UIViewController {