This file contains 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 | |
extension View { | |
/// Proposes a percentage of its received proposed size to `self`. | |
/// | |
/// This modifier multiplies the proposed size it receives from its parent | |
/// with the given factors for width and height. | |
/// | |
/// If the parent proposes `nil` or `.infinity` to us in any dimension, | |
/// we’ll forward these values to our child view unchanged. |
This file contains 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 Foundation | |
// NOTE: This playground shows how to use Swift's AttributedString with Markdown. | |
// | |
// This code was used to display Markdown content in the Tot iOS Widget <https://tot.rocks> | |
// MARK: - Helpful Links | |
// NOTE: The following links helped me figure this stuff out. |
This file contains 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
// | |
// FreeSpaceViewController.swift | |
// Free Space | |
// | |
// Created by Kyle Howells on 04/05/2022. | |
// | |
import UIKit | |
class FreeSpaceViewController: UIViewController { |
This file contains 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
class ViewController: UIViewController { | |
// 1 | |
@IBOutlet weak var tableView: UITableView! | |
// 2 | |
let sectionTitles = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".map(String.init) | |
} | |
extension ViewController: UITableViewDataSource { |
This file contains 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
//: Playground - noun: a place where people can play | |
import UIKit | |
import Foundation | |
import PlaygroundSupport | |
let allStates = ["Alaska", | |
"Alabama", | |
"Arkansas", | |
"American Samoa", |
This file contains 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 { | |
@State var pictureExpanded = false | |
var body: some View { | |
VStack(alignment: .leading, spacing: 20.0) { | |
Text("Once upon a time there was a turtle named George who made friends with a giraffe at the local water park and then they went on lots of adventures together.") | |
Button { |
This file contains 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
func mostRecentWorkouts(for healthStore: HKHealthStore, limit: Int) async throws -> [HKWorkout] { | |
let query = HKSampleQueryDescriptor( | |
predicates: [.workout()], | |
sortDescriptors: [SortDescriptor(\.endDate, order: .reverse)], | |
limit: limit | |
) | |
return try await query.result(for: healthStore) | |
} |
This file contains 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 | |
extension UITextField { | |
/// Add a trailing placeholder label that tracks the text as it changes | |
func addTrailingPlaceholder(_ placeholder: String) { | |
let label = UILabel() | |
label.text = placeholder | |
label.alpha = 0.3 | |
label.isHidden = true | |
addSubview(label) |
This file contains 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
// | |
// 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 |
This file contains 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
// | |
// ContentView.swift | |
// TryGeometryReader | |
// | |
// Created by satoutakeshi on 2019/12/07. | |
// Copyright © 2019 satoutakeshi. Licensed under MIT. | |
// | |
import SwiftUI |
NewerOlder