Font Custom Extension In Swift

[Solved] Font Custom Extension In Swift | Vb - Code Explorer | yomemimo.com
Question : custom font programmatically in swift

Answered by : md-murad-hossain

import UIKit
import Foundation
extension UIFont{ public enum SFProDisplayType: String { case regular = "Regular" case semiBold = "Semibold" case medium = "Medium" case bold = "Bold" case heavy = "Heavy" case light = "Light" case black = "Black" } static func SFProDisplay(_ type: SFProDisplayType = .regular, size: CGFloat = UIFont.systemFontSize) -> UIFont { return UIFont(name: "SFProDisplay-\(type.rawValue)", size: size)! } var isBold: Bool { return fontDescriptor.symbolicTraits.contains(.traitBold) } var isItalic: Bool { return fontDescriptor.symbolicTraits.contains(.traitItalic) }
}

Source : | Last Update : Tue, 24 Oct 23

Question : swiftui custom font extension

Answered by : isaac-iniongun

{"tags":[{"tag":"textarea","content":"\/\/MARK: Font Extension\nextension Font {\n enum ManropeFont {\n case semibold\n case custom(String)\n \n var value: String {\n switch self {\n case .semibold:\n return \"Semibold\"\n \n case .custom(let name):\n return name\n }\n }\n }\n \n enum RobotoFont {\n case semibold\n case custom(String)\n \n var value: String {\n switch self {\n case .semibold:\n return \"Semibold\"\n \n case .custom(let name):\n return name\n }\n }\n }\n \n static func manrope(_ type: ManropeFont, size: CGFloat = 26) -> Font {\n return .custom(type.value, size: size)\n }\n \n static func roboto(_ type: RobotoFont, size: CGFloat = 26) -> Font {\n return .custom(type.value, size: size)\n }\n}","code_language":"whatever"}]}

Source : https://stackoverflow.com/questions/67700147/adding-custom-fonts-as-an-extension-to-the-font-type-swiftui | Last Update : Sat, 10 Jun 23

Answers related to font custom extension in swift

Code Explorer Popular Question For Vb