Skip to content

Instantly share code, notes, and snippets.

View MTattin's full-sized avatar
:octocat:

Masakiyo Tachikawa MTattin

:octocat:
View GitHub Profile
@MTattin
MTattin / file0.swift
Created December 2, 2018 01:10
AVAssetTrackの向き判定を調べたのでメモ(画面録画も) ref: https://qiita.com/MTattin/items/45a263354279109e4983
extension AVAssetTrack {
///
// MARK: ------------------------------ properties
///
/// 動画の向き確認
///
var type: String {
if 0 < self.preferredTransform.b && self.preferredTransform.c < 0 && self.preferredTransform.tx == self.naturalSize.height {
return "ホーム下 or フロントホーム下"
}
@MTattin
MTattin / file0.swift
Last active November 19, 2017 07:08
アプリ内課金でCodableを利用する ref: https://qiita.com/MTattin/items/3d5507efc39e73cd57f1
///
/// ReceiptDetail
///
struct ReceiptDetail: Codable {
let receipt_type: String
let adam_id: Int
let app_item_id: Int
let bundle_id: String
let application_version: String
let download_id: Int
@MTattin
MTattin / file0.swift
Created September 22, 2017 05:10
safeAreaInsets.top と status bar のメモ ref: http://qiita.com/MTattin/items/224746049bbd849c49f4
///
/// Safe Area Insets
///
var SAFE: UIEdgeInsets {
get {
if #available(iOS 11.0, *) {
if let insets = AppDelegate?.window?.safeAreaInsets {
return insets
}
}
@MTattin
MTattin / file0.swift
Created August 16, 2017 10:20
swift4の文字列操作(Substring)メモ ref: http://qiita.com/MTattin/items/f97d1a51efd8eac109cf
///
/// 対象文字列
///
let str: String = "1234567890"
///
/// 先頭1文字 - 1
///
print("先頭1文字: \(String(str.prefix(1)))")
///
/// 先頭1文字以外 - 234567890
@MTattin
MTattin / file0.swift
Last active August 7, 2017 22:50
iOS11のColor Setを使いたいので、UIColorにextensionを追加してみた ref: http://qiita.com/MTattin/items/c4031fb6c2799baf005c
extension UIColor {
///
/// UIColor.init(named: String)がiOS11以降からしか使えないのでiOS10用処理
///
static func Init(named: String) -> UIColor {
if #available(iOS 11.0, *) {
guard let _0_c: UIColor = UIColor.init(named: named) else {
return UIColor.clear
}
return _0_c
@MTattin
MTattin / file0.swift
Last active September 5, 2020 13:17
UINavigationControllerのデフォルトの戻るボタンを除去する ref: http://qiita.com/MTattin/items/2e43926869585e7011ae
///
/// CstmNV - 戻るボタン非表示
///
class CstmNC: UINavigationController {
///
// MARK: ------------------------------ life cycle
///
///
///
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
UIFont.init(name: "PostScript名", size: 12)
@MTattin
MTattin / file0.swift
Created April 11, 2017 11:04
タップジェスチャをコールバックで(swift3) ref: http://qiita.com/MTattin/items/36d66f1f08235c382cf3
import UIKit
///
/// ベースビュー
///
class V: UIView, UIGestureRecognizerDelegate {
// MARK: ------------------------------ UIGestureRecognizer
///
/// コールバック関数
@MTattin
MTattin / file0.swift
Created February 26, 2017 10:09
Cocoaでswift3.0の画像リサイズ ref: http://qiita.com/MTattin/items/39bd9fd729adef67b205
#!/usr/bin/swift
import Cocoa
class fileMG {
var dir: String
var file: String
@MTattin
MTattin / file0.swift
Last active November 22, 2016 22:10
テーブルビューコントローラーのデリゲートメモ ref: http://qiita.com/MTattin/items/08f648b051ebec45604e
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
/// 0.0だと33pxの余白が発生したので0.1を定義