Skip to content

Instantly share code, notes, and snippets.

@JonFir
JonFir / DeviceModel.swift
Created March 29, 2016 04:26
Get device model in Swift
import UIKit
public extension UIDevice {
var modelName: String {
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
let identifier = machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8 where value != 0 else { return identifier }
@JonFir
JonFir / storage.swift
Created December 25, 2016 03:53 — forked from avdyushin/storage.swift
CoreData stack for iOS 9 and iOS 10 using Swift 3
//
// Storage.swift
//
// Created by Grigory Avdyushin on 30.06.16.
// Copyright © 2016 Grigory Avdyushin. All rights reserved.
//
import UIKit
import CoreData
import UIKit
extension NSAttributedString {
static func makeAtributes(
font: UIFont,
lineSpacing: CGFloat? = nil,
characterSpacing: CGFloat? = nil,
color: UIColor? = nil
) -> [String: Any] {
import UIKit
protocol CellViewModelActionable {
typealias Action = () -> Void
var onClick: Action? { get }
}
protocol CellViewModel {
static var cellAnyType: UIView.Type { get }
func setupAny(cell: UIView)
- (CAAnimationGroup*)makeSuccessIconAnimation
{
CGFloat const animationDuration = 0.4;
CAAnimationGroup *animation = [CAAnimationGroup animation];
animation.delegate = self;
[animation setValue:_successIconAnimationId forKey:_animationIdKeyName];
CABasicAnimation *appearAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
appearAnimation.fromValue = @0.0;
appearAnimation.toValue = @1.0;
@JonFir
JonFir / Icon
Created January 20, 2018 06:48
/**
Слой с иконкой
*/
@property (weak, nonatomic) CAShapeLayer *iconLayer;
@end
@implementation YTSSuccessIconView
- (instancetype)init
@JonFir
JonFir / Example.swift
Last active October 31, 2019 07:08
UsselesRefactoring#1
// 0. Default. Xcode generating.
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
let contentView = ContentView()