幅1pxの横線または縦線を描画する場合。
// 線幅
CGFloat wide = 1.0f / [UIScreen mainScreen].scale;
UIView *horizontal = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, wide)];
@interface UIView (UIViewFrame) | |
// frame.origin を取得 | |
- (CGPoint)origin; | |
- (CGFloat)x; | |
- (CGFloat)y; | |
// frame.size を取得 | |
- (CGSize)size; | |
- (CGFloat)width; |
import Cocoa | |
// This will work with Swift 5 | |
extension NSImage { | |
func image(with tintColor: NSColor) -> NSImage { | |
if self.isTemplate == false { | |
return self | |
} | |
let image = self.copy() as! NSImage |
// | |
// UIView+Frame.swift | |
// | |
// Created by M.Satori on 16.03.07. | |
// Copyright © 2016 usagimaru. | |
// | |
import UIKit | |
extension UIView { |
// | |
// 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 |
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) { |
import UIKit | |
extension UIScrollView { | |
/// ms 後にスクロールインジケーターを表示 | |
func flashScrollIndicators(afterIn milliseconds: Int = 500) { | |
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .milliseconds(milliseconds)) {[weak self] in | |
self?.flashScrollIndicators() | |
} | |
} |
import UIKit | |
extension UIView { | |
@IBInspectable var borderColor: UIColor? { | |
get { | |
if let c = layer.borderColor { | |
return UIColor(cgColor: c) | |
} | |
return nil |