Skip to content

Instantly share code, notes, and snippets.

View nickkohrn's full-sized avatar

Nick Kohrn nickkohrn

  • Lima, OH
  • 14:43 (UTC -05:00)
View GitHub Profile
nickkohrn / SubscriptedTextView
Created July 17, 2020 23:14
A SwiftUI View used to display strings with subscripted text
View SubscriptedTextView
import SwiftUI
struct SubscriptedTextView: View {
// MARK: Properties
let abbreviation: String
var body: some View {
nickkohrn / CurrencyService.swift
Last active July 15, 2017 16:00
This gist provides code for handling appropriate live-formatting of currency input for the current locale with respect to the placement of the currency's symbol.
View CurrencyService.swift
internal final class CurrencyService {
// MARK: - Currency Symbol Position
internal static var currencySymbolPosition: CurrencySymbolPosition {
let currencyFormat = CFNumberFormatterGetFormat(CFNumberFormatterCreate(nil, Locale.current as CFLocale, .currencyStyle)) as NSString
let positiveNumberFormat = currencyFormat.components(separatedBy: ";")[0] as NSString
let currencySymbolLocation = positiveNumberFormat.range(of: "¤").location
let position: CurrencySymbolPosition = currencySymbolLocation == 0 ? .before : .after
return position

Keybase proof

I hereby claim:

  • I am nickkohrn on github.
  • I am nickkohrn ( on keybase.
  • I have a public key ASARV_fuy9441BsWcBeiF9QGLYlBK2xPbOD088fRMhF0_wo

To claim this, I am signing this object: