Skip to content

Instantly share code, notes, and snippets.

View fittingpath.swift
/// Takes an absolute path and fits it inside the proposed rectangle.
struct FittingShape: Shape {
var absolutePath: Path
func path(in rect: CGRect) -> Path {
let p = absolutePath
let boundingRect = p.boundingRect
let scale = min(rect.width/boundingRect.width, rect.height/boundingRect.height)
let scaled = p.applying(.init(scaleX: scale, y: scale))
let scaledBoundingRect = scaled.boundingRect
@chriseidhof
chriseidhof / ContentView.swift
Created Feb 20, 2021 — forked from steipete/ContentView.swift
FB9013209: SwiftUI: Preview and actual layout differ in this example. (SwiftUI Bug)
View ContentView.swift
//
// ContentView.swift
// Shared
//
// Created by Peter Steinberger on 20.02.21.
//
import SwiftUI
struct SettingsGroup<Content: View>: View {
View LayoutPlayground.swift
//: A Cocoa based Playground to present user interface
import SwiftUI
struct ContentView: View {
var body: some View {
HStack {
Text("Highlight :")
.background(Color.green)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)
View engin.swift
//
// ContentView.swift
// WeatherWidget
//
// Created by Chris Eidhof on 20.01.21.
//
import SwiftUI
struct MyGuide: AlignmentID {
View picker.swift
import SwiftUI
let items = ["Basic", "Advanced", "Ultra"]
struct ContentView: View {
@State var value: Int = 0
var body: some View {
VStack {
Picker(selection: $value, label: Text("Mode:")) {
@chriseidhof
chriseidhof / Alt.swift
Last active Jul 13, 2020
matchedGeometryEffect experiments
View Alt.swift
//
// ContentView.swift
// Effects
//
// Created by Chris Eidhof on 13.07.20.
//
import SwiftUI
struct MyModifier: AnimatableModifier {
View tabs.swift
//
// ContentView.swift
// TabBar
//
// Created by Chris Eidhof on 13.07.20.
//
import SwiftUI
struct ContentView: View {
View alsobroken.swift
//
// ContentView.swift
// AddressBook
//
// Created by Chris Eidhof on 13.07.20.
//
import SwiftUI
final class Contact: ObservableObject, Identifiable {
View bug1.swift
//
// ContentView.swift
// Bug1
//
// Created by Chris Eidhof on 03.07.20.
//
import SwiftUI
struct ContentView: View {
View notesclone.swift
//
// ContentView.swift
// NotesClone
//
// Created by Chris Eidhof on 29.06.20.
//
import SwiftUI
@main