Skip to content

Instantly share code, notes, and snippets.

View iMostfa's full-sized avatar
🤪
ⓘ 𝗢𝗳𝗳𝗶𝗰𝗶𝗮𝗹 𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝘀𝘁𝗮𝘁𝗲𝗱 𝘁𝗵𝗮𝘁 𝘁𝗵𝗶𝘀 𝗶𝘀 𝗳𝗮𝗹𝘀𝗲 𝗮𝗻𝗱 𝗺𝗶𝘀𝗹𝗲𝗮𝗱𝗶𝗻𝗴

iMostfa

🤪
ⓘ 𝗢𝗳𝗳𝗶𝗰𝗶𝗮𝗹 𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝘀𝘁𝗮𝘁𝗲𝗱 𝘁𝗵𝗮𝘁 𝘁𝗵𝗶𝘀 𝗶𝘀 𝗳𝗮𝗹𝘀𝗲 𝗮𝗻𝗱 𝗺𝗶𝘀𝗹𝗲𝗮𝗱𝗶𝗻𝗴
View GitHub Profile
@steipete
steipete / AnchorButton.swift
Last active October 15, 2022 02:52
SwiftUI Button that wraps a hidden view to anchor popovers on it; can be used as a button in the navigation bar. https://pspdfkit.com/blog/2020/popovers-from-swiftui-uibarbutton/
struct AnchorButton<Content: View>: View {
typealias Action = (_ sender: AnyObject?) -> Void
let callback: Action
var content: Content
@StateObject private var viewWrapper = ViewWrapper(view: UIView(frame: .zero))
init(action: @escaping Action, @ViewBuilder label: () -> Content) {
self.callback = action
self.content = label()
}
@Snowy1803
Snowy1803 / ContentView.swift
Last active July 28, 2023 01:37
This code allows you to use matchedGeometryEffect in SwiftUI while keeping iOS 13 compatibility in your app.
//
// ContentView.swift
// Example of using matchedGeometryEffect in iOS 13 code
// matchedGeometryEffect example code taken and adapted from :
// https://sarunw.com/posts/a-first-look-at-matchedgeometryeffect/
//
// Created by Emil Pedersen on 16/10/2020.
//
struct ContentView: View {
@MichaelBarney
MichaelBarney / SwiftUI_Ad_Interstitial.swift
Created October 22, 2019 12:15
A google AdMob Interstitial implementation in SwiftUI
import SwiftUI
import GoogleMobileAds
import UIKit
final class Interstitial:NSObject, GADInterstitialDelegate{
var interstitial:GADInterstitial = GADInterstitial(adUnitID: interstitialID)
override init() {
super.init()
LoadInterstitial()
@literalpie
literalpie / scenekit-better-pan-gesture-recognizer.swift
Last active January 28, 2021 21:35
a better approach to handling the pan gesture in scenekit. For use in part 3 of medium post
@objc func handlePan(panGesture: UIPanGestureRecognizer) {
guard let view = view as? SCNView else { return }
let location = panGesture.location(in: self.view)
switch panGesture.state {
case .began:
// existing logic from previous approach. Keep this.
guard let hitNodeResult = view.hitTest(location, options: nil).first else { return }
panStartZ = CGFloat(view.projectPoint(lastPanLocation!).z)
// lastPanLocation is new
lastPanLocation = hitNodeResult.worldCoordinates