Skip to content

Instantly share code, notes, and snippets.

View yusuke024's full-sized avatar

Yusuke Onishi yusuke024

  • Google
  • Tokyo, Japan
View GitHub Profile
import UIKit
import PlaygroundSupport
class QRCodeView: UIView {
lazy var filter = CIFilter(name: "CIQRCodeGenerator")
lazy var imageView = UIImageView()
override init(frame: CGRect) {
super.init(frame: frame)
addSubview(imageView)
//
// CameraController.swift
//
import AVFoundation
import Photos
import UIKit
class CameraController: UIViewController {
enum Camera {
@yusuke024
yusuke024 / ViewController.swift
Created November 16, 2018 03:15
Recording video with AVAssetWriter
import UIKit
import AVFoundation
class ViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .notDetermined:
@yusuke024
yusuke024 / note.md
Last active July 27, 2018 07:14
Note on UIKit

Note on UIViewControllerAnimatedTransitioning and UIViewControllerInteractiveTransitioning

UINavigationController

  • Do not pass true to UIView.snapshotView(afterScreenUpdates:) when create a snapshot for animated transition object (false is fine).
  • Don't call animator.startAnimation() or animator.pauseAnimator() in startInteractiveTransition(_:)
  • If interruptibleAnimator(using:) is implemented, UINavigationController will observe fractionComplete from the returned animator object (not confirmed but very likely) and will animate the navigation bar accordingly to that value. Calling UIViewControllerContextTransitioning.updateInteractiveTransition(_:) will almost have no effect on the navigation bar animation (but you should call it anyway).
  • If interruptibleAnimator(using:) is not implemented, UINavigationController will use values that are passed to UIViewControllerContextTransitioning.updateInteractiveTransition(_:) to animate the navigation bar.

UINavigationBar

import XCTest
final class Static {
func a() { 1 + 1 }
func b() { a() }
func c() { b() }
}
class Dynamic {
func a() { 1 + 1 }
@yusuke024
yusuke024 / PlaygroundXCTest.swift
Last active March 31, 2021 17:44
Run XCTest in playground
import XCTest
class MyTestCase: XCTestCase {
func testExample() {
measure {
// Code to measure
}
}
}
import RxSwift
///
/// The operators can be generated by running the below code with Swift 4
///
//
//let methodCount = 6
//
//print("""
//extension ObservableType {
//: A UIKit based Playground to present user interface
import UIKit
import Vision
import PlaygroundSupport
class ViewController : UIViewController {
let imageView = UIImageView()
let overlayImageView = UIImageView()
import UIKit
struct Point {
let x: Double
let y: Double
}
extension Point {
static let zero = Point(x: 0, y: 0)
// Protocols
protocol Serializable {
func serialized() -> String
}
protocol Field: Serializable {
// ...
}