Skip to content

Instantly share code, notes, and snippets.

View onevcat's full-sized avatar
🐭

Wei Wang onevcat

🐭
View GitHub Profile
final class ViewController: UIPageViewController {
class Inner: UIViewController {
var color: UIColor!
var name: String!
override func viewDidLoad() {
view.backgroundColor = color
}
struct ContentView: View {
let foo: Bool = true
var body: some View {
Button(action: {
print("miao")
}) {
Text("Click Me")
}.buttonStyle(MyButtonStyle())
}
}
import SwiftUI
class Foo: ObservableObject {
@Published var toggle = false
}
struct ContentView: View {
@EnvironmentObject var foo: Foo
var body: some View {
VStack {
@onevcat
onevcat / files.txt
Last active February 7, 2019 13:14
https://github.com/sagood/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf
https://github.com/KocoClass/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf
https://github.com/wujungao/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf
https://github.com/asd8855/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf
https://github.com/Yuanzc005/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf
https://github.com/199305a/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf
https://github.com/xuehaiwuya11/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf
https://github.com/leoAntu/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf
https://github.com/imthunder/awesome-iOS-resource/blob/master/Books/Swifter%20100个%20Swift%20必备%20Tips.pdf
https://github.com/Ericfengshi/awesome-iOS-resource/blob/master/Book
import UIKit
import WebKit
// Disableing `WKWebView` user zooming by returning `nil` in `UIScrollViewDelegate`'s
// `viewForZooming` delegate method.
// On iOS 12, the delegate method only called when set the web view itself as the
// scroll view delegate.
class WebView: WKWebView {}
//Solution goes in Sources
public struct Card: CustomStringConvertible {
enum Suit: String {
case spade = "♤", heart = "♡", club = "♧", diamond = "♢"
// It is not the standard Texas poker rule. All suits are considered equal.
// However, there is a test case to "brake tide by suit", in which "heart" is the largest.
var value: Int {
switch self {
// For Request and Response defination, see https://onevcat.com/2016/12/pop-cocoa-2/
// Define the possible requests
protocol Request {
// Every request should have a corresponding Response
// Here we want all response could contain error cases
associatedtype Response: ErrorResponsable & Decodable
//...
}
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
extension Notification {
struct UserInfoKey<ValueType>: Hashable {
let key: String
}
import UIKit
import PlaygroundSupport
struct ToDoItem {
let id: UUID
let title: String
init(title: String) {
self.id = UUID()
self.title = title
struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
internal var _storage: _ContiguousArrayStorageBase
internal func _initStorageHeader(count: Int, capacity: Int) {
#if _runtime(_ObjC)
let verbatim = _isBridgedVerbatimToObjectiveC(Element.self)
#else
let verbatim = false
#endif