Skip to content

Instantly share code, notes, and snippets.

View lappp9's full-sized avatar

Luke Parham lappp9

View GitHub Profile
xcodebuild -workspace <workspace-name> -scheme <target-name> -configuration 'Release' -derivedDataPath <build-location>
source '<URL_TO_REPOSITORY>'
pod repo push <REPO_NAME> <SPEC_NAME>.podspec
pod repo add <REPO_NAME> <SOURCE_URL>
DispatchQueue.global(qos: .userInitiated).async {
let decodedImage = decodedImage(image)
DispatchQueue.main.async {
self.layer.contents = decodedImage?.cgImage
}
}
func decodedImage(_ image: UIImage) -> UIImage? {
guard let newImage = image.cgImage else { return nil }
let colorSpace = CGColorSpaceCreateDeviceRGB()
let context = CGContext(data: nil, width: newImage.width, height: newImage.height, bitsPerComponent: 8, bytesPerRow: newImage.width * 4, space: colorSpace, bitmapInfo: CGImageAlphaInfo.noneSkipFirst.rawValue)
context?.draw(newImage, in: CGRect(x: 0, y: 0, width: newImage.width, height: newImage.height))
let drawnImage = context?.makeImage()
if let drawnImage = drawnImage {
@lappp9
lappp9 / setImage.swift
Last active March 17, 2018 03:06
setting an image
imageView.image = UIImage(named: imagePath)
extension UIImage {
func circularImage(withSize size: CGSize) -> UIImage {
let scale = UIScreen.main.scale
let circleRect = CGRect(x: 0, y: 0, width: size.width * scale, height: size.height * scale)
UIGraphicsBeginImageContextWithOptions(circleRect.size, false, scale)
let circlePath = UIBezierPath(roundedRect: circleRect, cornerRadius: circleRect.width/2.0)
circlePath.addClip()
draw(in: circleRect)
class RoundView: UIView {
override func draw(_ rect: CGRect) {
let ctx = UIGraphicsGetCurrentContext()
let bezierPath = UIBezierPath(roundedRect: rect, cornerRadius: 100)
bezierPath.addClip()
ctx?.addPath(bezierPath.cgPath)
image.draw(in: rect)
}
let insets = UIEdgeInsets(top: 5.0, left: 5.0, bottom: 5.0, right: 5.0)
let image = UIImage(named: "shadow")?.resizableImage(withCapInsets: insets, resizingMode: .stretch)
shadowView.image = image