This file contains 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 | |
extension CGFloat { | |
var int: Int { | |
return Int(self) | |
} | |
var px: CGFloat { | |
return self / UIScreen.main.scale |
This file contains 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
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 |
This file contains 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
{ | |
"title": "カスタム", | |
"rules": [ | |
{ | |
"description": "左option: 英数/右command: かな", | |
"manipulators": [ | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "left_option", |
This file contains 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
{ | |
"title": "カスタム", | |
"rules": [ | |
{ | |
"description": "control + return to esc", | |
"manipulators": [ | |
{ | |
"from": { | |
"key_code": "return_or_enter", | |
"modifiers": { |
This file contains 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
var minimumLineHeight: CGFloat = 0 | |
var maximumLineHeight: CGFloat = 0 | |
let paragraphSettings: [CTParagraphStyleSetting] = [ | |
CTParagraphStyleSetting(spec: .minimumLineHeight, valueSize: MemoryLayout<CGFloat>.size, value: &minimumLineHeight), | |
CTParagraphStyleSetting(spec: .maximumLineHeight, valueSize: MemoryLayout<CGFloat>.size, value: &maximumLineHeight) | |
] | |
// sizeof(T) ... MemoryLayout<T>.size | |
let paragraphStyle = CTParagraphStyleCreate(paragraphSettings, paragraphSettings.count) |
This file contains 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 Cocoa | |
extension NSView { | |
@IBInspectable var backgroundColor: NSColor? { | |
get { | |
guard let layer = layer, let backgroundColor = layer.backgroundColor else {return nil} | |
return NSColor(cgColor: backgroundColor) | |
} | |
set { |
This file contains 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 | |
extension UIView { | |
func resetScrollsToTop(_ targetScrollView: UIScrollView) { | |
if self is UIScrollView { | |
(self as! UIScrollView).scrollsToTop = self == targetScrollView | |
} | |
for v in subviews { | |
v.resetScrollsToTop(targetScrollView) |
This file contains 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 | |
extension UIImage { | |
func paintedImage(color: UIColor) -> UIImage { | |
UIGraphicsBeginImageContextWithOptions(size, false, 0.0) | |
let bounds = CGRectMake(0, 0, size.width, size.height) | |
let context = UIGraphicsGetCurrentContext() |
This file contains 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 MyView: NSView { | |
override func draw(_ dirtyRect: NSRect) { | |
super.draw(dirtyRect) | |
guard let ctx = NSGraphicsContext.current?.cgContext else {return} | |
var rects: UnsafePointer<NSRect>? | |
var count = 0 | |
self.getRectsBeingDrawn(&rects, count: &count) |
This file contains 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 Cocoa | |
class MyConstraintLayoutManager: CAConstraintLayoutManager { | |
var isImplicitAnimationsDisabled: Bool = true | |
override func layoutSublayers(of layer: CALayer) { | |
// サブレイヤーのレイアウト時の暗黙アニメーションを無効化 | |
CATransaction.begin() | |
CATransaction.setDisableActions(self.isImplicitAnimationsDisabled) |