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
import UIKit | |
import PlaygroundSupport | |
final class CardView: UIControl { | |
private let imageView = UIImageView(image: UIImage(named: "Sample")) | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
layer.cornerRadius = 9 |
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
import SwiftUI | |
struct TestCard: View { | |
private let cornerRadius: CGFloat = 12 | |
@Environment(\.displayScale) private var displayScale | |
@State private var isSelected = false | |
var body: some View { |
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
import UIKit | |
extension UIImage { | |
var averageColor: UIColor? { | |
guard let inputImage = self.ciImage ?? CIImage(image: self) else { return nil } | |
guard let filter = CIFilter(name: "CIAreaAverage", parameters: [kCIInputImageKey: inputImage, kCIInputExtentKey: CIVector(extent: inputImage.extent)]) | |
else { return nil } | |
guard let outputImage = filter.outputImage else { return nil } |
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
import UIKit | |
fileprivate enum PathElement { | |
case moveToPoint(CGPoint) | |
case addLineToPoint(CGPoint) | |
case addQuadCurveToPoint(CGPoint, CGPoint) | |
case addCurveToPoint(CGPoint, CGPoint, CGPoint) | |
case closeSubpath | |
} |
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 UIFont { | |
var withSmallCaps: UIFont { | |
let upperCaseFeature = [ | |
UIFontDescriptor.FeatureKey.type : kUpperCaseType, | |
UIFontDescriptor.FeatureKey.selector : kUpperCaseSmallCapsSelector | |
] | |
let lowerCaseFeature = [ | |
UIFontDescriptor.FeatureKey.type : kLowerCaseType, | |
UIFontDescriptor.FeatureKey.selector : kLowerCaseSmallCapsSelector |
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 NSBezierPath { | |
/// A `CGPath` object representing the current `NSBezierPath`. | |
var cgPath: CGPath { | |
let path = CGMutablePath() | |
let points = UnsafeMutablePointer<NSPoint>.allocate(capacity: 3) | |
if elementCount > 0 { | |
var didClosePath = true |
NewerOlder