Skip to content

Instantly share code, notes, and snippets.

View nissivm's full-sized avatar

Nissi Miranda nissivm

View GitHub Profile
@SergLam
SergLam / GradientLabel.swift
Created January 11, 2021 22:06
Gradient Label for iOS in Swift
import UIKit
final class GradientLabel: UILabel {
private var colors: [UIColor] = [.supAzure, .supAppleFive]
private var startPoint: CGPoint = CGPoint(x: 0.0, y: 0.5)
private var endPoint: CGPoint = CGPoint(x: 1.0, y: 0.5)
@mahmudahsan
mahmudahsan / ios_detect.swift
Last active July 9, 2021 09:07
iPhone X and other iOS device detection by Swift and Objective-C
struct Device {
// iDevice detection code
static let IS_IPAD = UIDevice.current.userInterfaceIdiom == .pad
static let IS_IPHONE = UIDevice.current.userInterfaceIdiom == .phone
static let IS_RETINA = UIScreen.main.scale >= 2.0
static let SCREEN_WIDTH = Int(UIScreen.main.bounds.size.width)
static let SCREEN_HEIGHT = Int(UIScreen.main.bounds.size.height)
static let SCREEN_MAX_LENGTH = Int( max(SCREEN_WIDTH, SCREEN_HEIGHT) )
static let SCREEN_MIN_LENGTH = Int( min(SCREEN_WIDTH, SCREEN_HEIGHT) )
@ayakix
ayakix / NSNotificationName+Extension.swift
Last active June 6, 2021 12:58
Define custom NSNotification.Name
// NSNotification.Name拡張
extension NSNotification.Name {
static let sample = Notification.Name(rawValue: "sample")
// static let hoge = Notification.Name(rawValue: "hoge")
// static let fuga = Notification.Name(rawValue: "fuga")
}
/////////////////////////////////////////////////////////////////////////////////////////////
// 通知発行側コード
@erica
erica / gist:999dabc1a2d176bce3ec
Last active February 11, 2017 01:40
Composed character count
extension String {
var composedCount : Int {
var count = 0
enumerateSubstringsInRange(startIndex..<endIndex, options: .ByComposedCharacterSequences) {_ in count++}
return count
}
}