Skip to content

Instantly share code, notes, and snippets.

View hiddevdploeg's full-sized avatar

Hidde van der Ploeg hiddevdploeg

View GitHub Profile
@hiddevdploeg
hiddevdploeg / SF-Expanded.swift
Last active August 23, 2022 12:14
Expanded and Condensed Font for SwiftUI
public extension Font {
init(uiFont: UIFont) {
self = Font(uiFont as CTFont)
}
static func expanded(_ style: UIFont.TextStyle, size: CGFloat? = nil, weight: Font.Weight = .regular) -> Font {
var descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style)
let traits: [UIFontDescriptor.TraitKey:Any] = [.width: 1.5]
descriptor = descriptor.addingAttributes([.traits: traits])
@hiddevdploeg
hiddevdploeg / deeplink-health.swift
Created April 3, 2019 23:19
Deeplink to health app on iOS
@hiddevdploeg
hiddevdploeg / Weight.swift
Last active October 30, 2016 16:32
Why is the LatestMeasure function returning empty values?
//
// Weight.swift
// Vekt
//
// Created by Hidde van der Ploeg on 26/09/2016.
// Copyright © 2016 Hidde van der Ploeg. All rights reserved.
//
import UIKit
import HealthKit
@hiddevdploeg
hiddevdploeg / imageURL.swift
Last active July 11, 2016 19:12
Easy function to return a single image from an URL
func imageURL(URL: String) -> UIImage {
guard let base = NSURL(string: URL),
let data = NSData(contentsOfURL: base),
let image = UIImage(data:data) else {
return nil
}
return image
}
//USAGE EXAMPLE: imagevar.image = imageURL("http://logonoid.com/images/star-wars-logo.png")