This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Array where Element: Hashable { | |
func difference(from other: [Element]) -> [Element] { | |
let thisSet = Set(self) | |
let otherSet = Set(other) | |
return Array(thisSet.symmetricDifference(otherSet)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you’re seeing CP Specs issues, or even if you’re not. We’d recommend running: | |
cd ~/.cocoapods/repos/master && git fetch --unshallow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let v = UIView(frame: .zero) | |
let l1 = UILabel(frame: .zero) | |
l1.translatesAutoresizingMaskIntoConstraints = false | |
l1.font = .systemFont(ofSize: 27.0) | |
l1.text = "asdlas" | |
v.addSubview(l1) | |
NSLayoutConstraint.activate([ | |
l1.topAnchor.constraint(equalTo: v.topAnchor), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
capacity / 1024 | |
ByteCountFormatter.string(fromByteCount: Int64(capacity), countStyle: .file) | |
ByteCountFormatter.string(fromByteCount: Int64(capacity), countStyle: .memory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Изменение размеров CALayer'a лежит полностью на его пользователе. | |
Поэтому вам нужно при каждом изменении frame у вью, менять положиние / размер слоя | |
Пример: | |
class MyView: UIView { | |
let gradient: CALayer | |
... | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
gradient.frame = self.bounds | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KEYWORDS="TODO|FIXME|\?\?\?:|\!\!\!:" | |
find "${SRCROOT}" \( -name "*.swift" \) -print0 | \ | |
xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | \ | |
perl -p -e "s/($KEYWORDS)/ warning: \$1/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Array where Element: Equatable { | |
mutating func delete(_ element: Element) { | |
self = self.filter { $0 != element } | |
} | |
mutating func removeObject<T>(_ element: T) where T : Equatable { | |
self = self.filter {$0 as? T != element} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UILabel+FontSize.Swift | |
// | |
// Created by Nutchaphon Rewik on 7/11/15. | |
// Copyright (c) 2015 Nutchaphon Rewik. All rights reserved. | |
// | |
import UIKit | |
extension UILabel{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CVError.swift | |
// | |
// Created by Jun Tanaka on 2016/12/13. | |
// Copyright © 2016 Jun Tanaka. All rights reserved. | |
// | |
import CoreVideo | |
public enum CVError: Int32, Error { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation CIContext (IntermediateImage) | |
- (CIImage *)rsq_renderToIntermediateImage:(CIImage *)image { | |
CIImage *intermediateImage = nil; | |
CGSize size = image.extent.size; | |
CVPixelBufferRef pixelBuffer = NULL; | |
CVReturn status = CVPixelBufferCreate(kCFAllocatorDefault, | |
size.width, | |
size.height, | |
kCVPixelFormatType_32ARGB, |
NewerOlder