Skip to content

Instantly share code, notes, and snippets.

@yoman07
yoman07 / svg-convert.sh
Created February 8, 2019 08:02 — forked from zolthan/svg-convert.sh
Convert SVG to PNG @2x @3x
#!/bin/bash
# I made this script to convert SVG icons for an iOS app into PNG.
# The script will create icons in 3 sizes for different screen DPIs.
find . -type f -name "*.svg" | while read f
do
echo '---'
FILENAME="${f%.*}"
echo $FILENAME
@yoman07
yoman07 / CornerInsideView
Created March 29, 2018 15:11
View with inside corners
final class CornerInsideView: UIView {
var corner: UIRectCorner? {
didSet {
setup()
}
}
var radius: CGFloat = 0
private func setup() {
@yoman07
yoman07 / Stripedgradientview.playground
Last active January 5, 2018 14:51
Striped gradient view
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
final class StripedGradientView: UIView {
@available(*, unavailable, message: "This property is reserved for Interface Builder. Use 'direction' instead.")
@IBInspectable var directionName: String? {
willSet {
@yoman07
yoman07 / AlertViewControllerImpl.swift
Last active November 17, 2017 14:15
Alert view controller abstraction
import Foundation
final class AlertViewControllerBuilder {
var title: String?
var message: String?
var okHandler: AnonymousActionClosure?
var cancelHandler: AnonymousActionClosure?
typealias BuilderClosure = (AlertViewControllerBuilder) -> Void
@yoman07
yoman07 / Dictionary with range
Created October 5, 2017 08:19
Thanks to this code you can create dictionary with enums and range
import Foundation
extension Dictionary where Key == Range<Float> {
subscript(bmi bmi: Float) -> Value? {
guard let k = keys.filter({$0 ~= bmi}).first else {
return nil
}
return self[k]
}
}
import UIKit
final class Action: NSObject {
private let _action: () -> ()
init(action: @escaping () -> ()) {
_action = action
super.init()
}
func action() {
_action()
import Foundation
extension Dictionary {
static func contentsOf(url: URL) -> Dictionary<Key, Value>? {
do {
let data = try Data(contentsOf:url)
let properties = try PropertyListSerialization.propertyList(from: data, options: [], format: nil) as? [Key: Value]
return properties
} catch {
return nil
}
@yoman07
yoman07 / Alert with fabric
Last active September 2, 2016 17:06
Display alert view with settings button
//
// AlertControllerFabric.swift
// Mapa Turystyczna
//
// Created by Roman Barzyczak on 05.04.2016.
//
import Foundation
class AlertHelper {
@yoman07
yoman07 / generateIcons
Created December 14, 2014 13:57
Generate icons for xcode
mkdir MyIcon
sips -z 29 29 Icon1024.png --out MyIcon/icon_29x29.png
sips -z 58 58 Icon1024.png --out MyIcon/icon_29x29@2x.png
sips -z 87 87 Icon1024.png --out MyIcon/icon_29x29@3x.png
sips -z 40 40 Icon1024.png --out MyIcon/icon_40x40.png
sips -z 80 80 Icon1024.png --out MyIcon/icon_40x40@2x.png
sips -z 120 120 Icon1024.png --out MyIcon/icon_40x40@3x.png
sips -z 50 50 Icon1024.png --out MyIcon/icon_50x50.png
@yoman07
yoman07 / stack.h
Created February 16, 2014 19:05
Stack objective-c
//
// Stack.h
// testing
//
// Created by Roman Barzyczak on 16.02.2014.
//
//
#import <Foundation/Foundation.h>