This file contains hidden or 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 { | |
var body: some View { | |
ViewThatFits { | |
MyCoolVStack() | |
ScrollView(.vertical) { MyCoolVStack() } | |
} | |
.background(Color.gray) | |
} |
This file contains hidden or 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 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 |
This file contains hidden or 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 | |
enum ShopState: Int { | |
case iceCream, flowers | |
} | |
struct ShopStatePreferenceKey: PreferenceKey { | |
static var defaultValue: ShopState = .iceCream | |
static func reduce(value: inout ShopState, nextValue: () -> ShopState) { |
This file contains hidden or 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
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) { |
This file contains hidden or 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
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) |
This file contains hidden or 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 { | |
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( |
This file contains hidden or 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 SpriteKit | |
class SKAnimatedAction { | |
let movementAction: SKAction | |
let animationAction: SKAction | |
let animationKey: String | |
init(movementAction: SKAction, animationAction: SKAction, animationKey: String) { | |
self.movementAction = movementAction |
This file contains hidden or 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
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) | |
} |
This file contains hidden or 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 AVFoundation | |
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { | |
let tableView = UITableView(frame: .zero, style: .plain) | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
tableView.register(PlayerTableViewCell.self, forCellReuseIdentifier: "PlayerCell") |
This file contains hidden or 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 | |
class ViewController: UIViewController { | |
let textViewWrapper = TextViewWrapper() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// The problem view! I want to add this one to my set of Auto Layout constraints, | |
// even though it's not using Auto Layout internally. |