If I have a JSON Codable object in Swift that looks like:
struct IceCreamStore: Codable {
let iceCreams: [IceCream: Int]
}
enum IceCream: String, Codable {
case chocolate, vanilla
}
If I have a JSON Codable object in Swift that looks like:
struct IceCreamStore: Codable {
let iceCreams: [IceCream: Int]
}
enum IceCream: String, Codable {
case chocolate, vanilla
}
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
ViewThatFits { | |
MyCoolVStack() | |
ScrollView(.vertical) { MyCoolVStack() } | |
} | |
.background(Color.gray) | |
} |
import UIKit | |
import SwiftUI | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let box = UIView() | |
box.frame = CGRect(x: (view.bounds.width / 2.0) - 100.0, y: 0.0, width: 100.0, height: 100.0) | |
box.backgroundColor = .systemGreen |
import SwiftUI | |
enum ShopState: Int { | |
case iceCream, flowers | |
} | |
struct ShopStatePreferenceKey: PreferenceKey { | |
static var defaultValue: ShopState = .iceCream | |
static func reduce(value: inout ShopState, nextValue: () -> ShopState) { |
struct ContentView: View { | |
var body: some View { | |
List { | |
Section { | |
VStack(alignment: .leading, spacing: 20.0) { | |
Image("example") // Natively 1179x787 | |
.resizable() | |
.scaledToFill() | |
VStack(alignment: .leading, spacing: 20.0) { |
var body: some View { | |
Color.black.opacity(0.2) | |
.frame(width: 180.0, height: 60.0) | |
.overlay( | |
VStack(alignment: .leading, spacing: 0.0) { | |
Text(input) | |
.font(.system(size: 12.0, weight: .semibold)) | |
.layoutPriority(1.0) | |
Spacer(minLength: 0.0) |
import SwiftUI | |
struct ContentView: View { | |
let text1 = "Hello this is some very long text that goes on for quite awhile which can make it tricky to display" | |
let text2 = "I am brief" | |
var body: some View { | |
Color.black.opacity(0.2) | |
.frame(width: 180.0, height: 60.0) | |
.overlay( |
import UIKit | |
import SpriteKit | |
class SKAnimatedAction { | |
let movementAction: SKAction | |
let animationAction: SKAction | |
let animationKey: String | |
init(movementAction: SKAction, animationAction: SKAction, animationKey: String) { | |
self.movementAction = movementAction |
override func didMove(to view: SKView) { | |
// I want my character to walk to a spot, then jump to a spot | |
let actionSequence = SKAction.sequence([walkingAction(), jumpingAction()]) | |
let node = SKSpriteNode(imageNamed: "character.png") | |
// The jumping action never occurs because the walking action never | |
// actually completes because the animation is repeating forever | |
node.run(actionSequence) | |
} |
import UIKit | |
import AVFoundation | |
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { | |
let tableView = UITableView(frame: .zero, style: .plain) | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
tableView.register(PlayerTableViewCell.self, forCellReuseIdentifier: "PlayerCell") |