Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View usagimaru's full-sized avatar
🐰

usagimaru usagimaru

🐰
View GitHub Profile
@usagimaru
usagimaru / gist:47002e03c10b4548bfc0
Last active August 29, 2015 14:13
Drawing 1px lines on iOS Device with Retina Display

UIView

幅1pxの横線または縦線を描画する場合。

// 線幅
CGFloat wide = 1.0f / [UIScreen mainScreen].scale;

UIView *horizontal = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, wide)];
@usagimaru
usagimaru / TFBonARC.md
Created January 14, 2015 06:13
Foundation/Core FoundationのToll-Free BridgingとARC

はじめに

ARC環境下ではFoundationオブジェクトとCore Foundationオブジェクトのキャストによる変換はいろいろと面倒になっているので要注意。

基本的に、

  • Foundation (NS):ARCの管理対象
  • Core Foundation (CF):MRC

使用する属性

@usagimaru
usagimaru / callout.md
Created January 14, 2015 06:15
Disabling callout and user selection on UIWebView

矩形選択を無効化する方法。コピー等のコンテクストメニューも出なくなる。

CSS

CSSに -webkit-touch-callout -webkit-user-select をぶち込んでおくだけ。

<style type="text/css">
<!--
* {
@usagimaru
usagimaru / UIViewFrame.h
Last active June 13, 2016 04:52
A pretty useful Objective-C category of UIView that accessing easily to UIView's frame.
@interface UIView (UIViewFrame)
// frame.origin を取得
- (CGPoint)origin;
- (CGFloat)x;
- (CGFloat)y;
// frame.size を取得
- (CGSize)size;
- (CGFloat)width;
@usagimaru
usagimaru / UIViewFrame.swift
Last active June 20, 2016 15:16
A pretty useful Swift extension of UIView that accessing easily to UIView's frame properties.
//
// UIView+Frame.swift
//
// Created by M.Satori on 16.03.07.
// Copyright © 2016 usagimaru.
//
import UIKit
extension UIView {
@usagimaru
usagimaru / IndexPathExtension.swift
Created March 7, 2017 07:10
IndexPathExtension.swift
import Foundation
extension IndexPath {
static func fromString(_ string: String) -> IndexPath? {
let strs = string.components(separatedBy: ",")
var indexPath = IndexPath.init()
for str in strs {
if let i = Int(str) {
@usagimaru
usagimaru / NetworkIndicatorManager.swift
Last active May 9, 2017 08:09
NetworkIndicatorManager.swift
//
// NetworkIndicatorManager.swift
//
// Created by Satori Maru on 15.11.27.
// Copyright (c) 2015 Satori Maru. All rights reserved.
//
import UIKit
private let kGeneralLifeKey: Int = -1
@usagimaru
usagimaru / UIScrollView.swift
Created May 9, 2017 08:14
UIScrollView extension.
import UIKit
extension UIScrollView {
/// ms 後にスクロールインジケーターを表示
func flashScrollIndicators(afterIn milliseconds: Int = 500) {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .milliseconds(milliseconds)) {[weak self] in
self?.flashScrollIndicators()
}
}
@usagimaru
usagimaru / UIView.swift
Created May 9, 2017 08:16
UIView extension.
import UIKit
extension UIView {
@IBInspectable var borderColor: UIColor? {
get {
if let c = layer.borderColor {
return UIColor(cgColor: c)
}
return nil
@usagimaru
usagimaru / init.lua
Created May 23, 2017 16:35
hammerspoon key config
local KEY_EISU = 0x66
local KEY_KANA = 0x68
local KEY_LCMD = 55
local KEY_RCMD = 54
local KEY_LOPT = 58
local KEY_ROPT = 61
local KEY_ESC = 53
local KEY_CTRL = 59
local KEY_RETURN = 52
local KEY_BSLASH = 42