Skip to content

Instantly share code, notes, and snippets.

@mralexhay
mralexhay / SwiftUI Tagger.swift
Last active March 11, 2024 06:35
A SwiftUI interface for adding tags
//
// TaggerView.swift
//
// Created by Alex Hay on 21/11/2020.
//
// Simple interface for adding tags to an array in SwiftUI
// Example video: https://imgur.com/gallery/CcA1IXp
// alignmentGuide code from Asperi @ https://stackoverflow.com/a/58876712/11685049
import SwiftUI
import SwiftUI
import UIKit
struct Sunset: View {
@State var backgroundColor = Color.blue
@State var sunSetted = false
let skyGradientDay = [Color(#colorLiteral(red: 0.2196078449, green: 0.007843137719, blue: 0.8549019694, alpha: 1)), Color(#colorLiteral(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1)), Color(#colorLiteral(red: 0.6254054655, green: 0.9221722869, blue: 0.9686274529, alpha: 1)), Color(#colorLiteral(red: 0.8345658875, green: 0.9221722869, blue: 0.9686274529, alpha: 1))]
let skyGradientNight = [Color(#colorLiteral(red: 0.2196078449, green: 0.007843137719, blue: 0.4246178452, alpha: 1)), Color(#colorLiteral(red: 0.8078431487, green: 0.02745098062, blue: 0.7072513187, alpha: 1)), Color(#colorLiteral(red: 0.8078431487, green: 0.02745098062, blue: 0.3333333433, alpha: 1)), Color(#colorLiteral(red: 0.8078431487, green: 0.2959635248, blue: 0.6193262317, alpha: 1))]
@mralexhay
mralexhay / TextField.swift
Last active March 12, 2022 11:50
Adding items with TextField
//
// ContentView.swift
// TextField
//
// Created by Alex Hay on 11/03/2022.
//
import SwiftUI
/*
@mralexhay
mralexhay / swift-navviews-in-tabview.swift
Last active April 21, 2022 01:47
SwiftUI NavViews in TabView
struct ContentView: View {
var body: some View {
TabView {
ForEach(0 ..< 13) { i in
ColorView(index: i)
}
}
.ignoresSafeArea(.all)
.navigationViewStyle(.stack)
.tabViewStyle(.page(indexDisplayMode: .never))