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 CGSize { | |
func sizeFittingPreservingAspectRatio(_ otherSize: CGSize) -> CGSize { | |
if height <= width { | |
let scaledWidth = (otherSize.height / height) * width | |
return CGSize(width: scaledWidth, height: otherSize.height) | |
} else { | |
let scaledHeight = (otherSize.width / width) * height | |
return CGSize(width: otherSize.width, height: scaledHeight) | |
} |
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 Foundation | |
import UIKit | |
public extension UIFont { | |
static func preferredFont(forTextStyle style: UIFont.TextStyle, weight: UIFont.Weight) -> UIFont { | |
let font = style.withWeight(weight) | |
let fontMetrics = UIFontMetrics(forTextStyle: style) | |
return fontMetrics.scaledFont(for: font) | |
} | |
} |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
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
af Afrikaans | |
af_NA Afrikaans (Namibia) | |
af_ZA Afrikaans (South Africa) | |
agq Aghem | |
agq_CM Aghem (Cameroon) | |
ak Akan | |
ak_GH Akan (Ghana) | |
am Amharic | |
am_ET Amharic (Ethiopia) | |
ar Arabic |
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 UIView { | |
func roundCorners(_ corners: Corners, radius: CGFloat) { | |
var cornerMasks = [CACornerMask]() | |
// Top left corner | |
switch corners { | |
case .all, .top, .topLeft, .allButTopRight, .allButBottomLeft, .allButBottomRight, .topLeftBottomRight: | |
cornerMasks.append(CACornerMask(rawValue: UIRectCorner.topLeft.rawValue)) | |
default: | |
break |
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
func generateQRCode(from data: Data) -> UIImage? { | |
if let filter = CIFilter(name: "CIQRCodeGenerator") { | |
filter.setValue(data, forKey: "inputMessage") | |
guard let qrCodeImage = filter.outputImage else { return nil } | |
let scaleX = self.codeView.frame.size.width / qrCodeImage.extent.size.width | |
let scaleY = self.codeView.frame.size.height / qrCodeImage.extent.size.height | |
let transform = CGAffineTransform(scaleX: scaleX, y: scaleY) | |