Skip to content

Instantly share code, notes, and snippets.

@enix223
enix223 / swift3-create-color-image.swift
Created November 29, 2016 05:09
Create an image with specific color
func imageWithColor(_ color: UIColor) -> UIImage {
let rect = CGRect(x: 0, y: 0, width: 1, height: 1)
UIGraphicsBeginImageContext(rect.size)
let context = UIGraphicsGetCurrentContext()
context!.setFillColor(color.cgColor)
context!.fill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return image
}
@enix223
enix223 / swift2-calculate-sha1.swift
Created November 3, 2016 04:33
Calculate SHA1 with Swift2
//
// TestSHA1Digest.swift
// SwiftPlayground
//
// Created by Enix Yu on 31/10/2016.
// Copyright © 2016 RobotBros. All rights reserved.
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !! Be sure to #import <CommonCrypto/CommonCrypto.h> in the bridging header file !!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!