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 | |
| private var menus: [String] = [ | |
| "cat", | |
| "car", | |
| "human", | |
| "robot", | |
| "coffee" | |
| ] |
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 | |
| import Combine | |
| // MARK: - Data | |
| class CurrentTime: ObservableObject { | |
| @Published var seconds = Double.zero | |
| private let timer = Timer.publish(every: 0.16, on: .main, in: .common).autoconnect() | |
| private var cancellableSet = Set<AnyCancellable>() | |
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 Data: Identifiable, Equatable { | |
| let id: UUID = .init() | |
| let value: String | |
| } | |
| struct ContentView: View { | |
| @Namespace var namespace | |
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 { | |
| private static let imageHeight: CGFloat = 300 | |
| @State private var offset: CGFloat = 0 | |
| var body: some View { | |
| ScrollView { |
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 ImageIO | |
| // make one shot gif animation from Gif. | |
| let gif = Gif(with: "GIF File Name (not in asset catalog)")! | |
| let base: Double = 4000 | |
| let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) | |
| // set start image before starting animation | |
| imageView.image = gif.frames.first |
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
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| // Cake PatternもどきをSwiftで実装したもの。要するにProtocolのコンポジションによって依存の定義、解決をしていく | |
| protocol Animal {} | |
| struct Cat: Animal {} |
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
| class TextView: UITextView { | |
| lazy var moreLabel: UILabel = { | |
| let label = UILabel() | |
| label.text = "さらに表示" | |
| label.textColor = .gray | |
| label.font = self.font | |
| label.textAlignment = .center | |
| return label | |
| }() |
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
| hoge |
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 PickerKeyboard: UIControl { | |
| var data: [String] = ["Mon.", "Tue.", "Wed.", "Thu.", "Fri.", "Sut.", "Sun."] | |
| fileprivate var textStore: String = "" | |
| override func draw(_ rect: CGRect) { | |
| UIColor.black.set() | |
| UIRectFrame(rect) |
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
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| import XCPlayground | |
| class MyViewController<Delegate: MyViewControllerDelegate>: UICollectionViewController, UICollectionViewDelegateFlowLayout { | |
| var delegate: AnyMyViewControllerDelegate<Delegate>? | |
| var items = [Array<Delegate.Item>]() { |
NewerOlder