Skip to content

Instantly share code, notes, and snippets.

Avatar

Frank Jia frankfka

View GitHub Profile
@frankfka
frankfka / iOSMultiSegmentPickerSwiftUI.swift
Created Jul 14, 2020
Multi-Segment Picker in SwiftUI
View iOSMultiSegmentPickerSwiftUI.swift
import SwiftUI
import PlaygroundSupport
struct MultiSegmentPickerViewModel {
typealias Label = String
typealias Selection = Binding<Int>
typealias PickerDisplayValues = [String]
let segments: [(Label, Selection, PickerDisplayValues)]
}
@frankfka
frankfka / iOSCustomSegmentedControlSwiftUI.swift
Created May 17, 2020
Custom Segmented Picker / Segmented Control in SwiftUI
View iOSCustomSegmentedControlSwiftUI.swift
import SwiftUI
extension View {
func eraseToAnyView() -> AnyView {
AnyView(self)
}
}
struct SizePreferenceKey: PreferenceKey {
typealias Value = CGSize
@frankfka
frankfka / iOSActivityRingSwiftUI.swift
Created Apr 29, 2020
iOS Activity Ring in SwiftUI
View iOSActivityRingSwiftUI.swift
import SwiftUI
import PlaygroundSupport
extension Double {
func toRadians() -> Double {
return self * Double.pi / 180
}
func toCGFloat() -> CGFloat {
return CGFloat(self)
You can’t perform that action at this time.