Skip to content

Instantly share code, notes, and snippets.

@churabou
churabou / TabBarViewController.swift
Created October 29, 2019 11:59
Custom TabBarViewController
import UIKit
extension UIColor {
convenience init(hex: UInt32, alpha: CGFloat = 1) {
let r = CGFloat((hex & 0xFF0000) >> 16) / 255
let g = CGFloat((hex & 0x00FF00) >> 8) / 255
let b = CGFloat(hex & 0x0000FF) / 255
self.init(red: r, green: g, blue: b, alpha: alpha)
}
}
@dynamicMemberLookup
struct Apply<Base: AnyObject> {
private let build: () -> Base
private init(_ build: @escaping () -> Base) {
self.build = build
}
init(_ base: Base) {
self.build = { base }
final class TooltipView: UIView {
private var option: Option!
init(option: Option) {
self.option = option
super.init(frame: .zero)
configure()
}
required init?(coder aDecoder: NSCoder) {
final class AnimationView: UIView {
private let shapeLayer: CAShapeLayer = {
let it = CAShapeLayer()
it.fillColor = UIColor.clear.cgColor
it.strokeColor = UIColor(hex: 0xFF598B).cgColor
it.lineWidth = 5
it.lineCap = .round
it.strokeEnd = 0
return it
}()
@churabou
churabou / UIView+Constraint.swift
Last active June 26, 2019 01:57
extension to easy code layout
extension UIView {
var layout: LayoutMaker {
return LayoutMaker(self)
}
}
protocol CGFloatConvertible {
var cgFloatValue: CGFloat { get }
}
@churabou
churabou / main.dart
Last active June 4, 2019 13:23
Flutter Qiita API Example
import 'dart:async';
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:webview_flutter/webview_flutter.dart';
class User {
final String id;
@churabou
churabou / SettingTable.swift
Created March 23, 2019 15:20
設定画面を2分で作るやつ
final class SettingTable: UITableView {
typealias SelectHandler = (IndexPath) -> ()
convenience init(sections: [[String]], onSelectRow: @escaping SelectHandler) {
self.init(frame: .zero, style: .grouped)
self.sections = sections
self.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
self.selectHandler = onSelectRow
self.delegate = self
@churabou
churabou / loadingCircleView.swift
Created March 23, 2019 07:16
loadingCircleView
final class LoadingCircleView: UIView {
private var shapeLayer: CAShapeLayer!
override func draw(_ rect: CGRect) {
let center = CGPoint(x: bounds.width / 2, y: bounds.height / 2)
let trackLayer = createTrackLayer(center: center, radius: 100, lineWidth: 10, strokeColor: .darkGray)
layer.addSublayer(trackLayer)
shapeLayer = createTrackLayer(center: center, radius: 100, lineWidth: 10, strokeColor: .orange)
shapeLayer.strokeEnd = 0
//
// ViewController.swift
// TableViewExample
//
// Created by churabou on 2018/11/08.
// Copyright © 2018 churabou. All rights reserved.
//
import UIKit
@churabou
churabou / test.md
Created November 18, 2018 06:46
test

aaa

bb

c