Recipies
extension UIFont {
var bold: UIFont {
guard let newDescriptor = fontDescriptor.withSymbolicTraits(.traitBold) else {
return self
}
return UIFont(descriptor: newDescriptor, size: pointSize)
}
}
public struct FontStyle: ViewModifier {
let isBold: Bool
private let font: Font
public init(isBold: Bool = false) {
self.isBold = isBold
self.font = self.font.bold
}
public func body(content: Self.Content) -> some View {
content.font(font)
}
}
extension View {
public func fontStyle(isBold: Bool = false) -> some View {
modifier(FontStyle(isBold: isBold))
}
}
Testing
class ExampleXCTestCase: XCTestCase {
let app = XCUIApplication()
override func tearDown() {
app.terminate()
}
override func tearDownWithError() throws {
app.terminate()
}
}
In tests (it has to be called before app.launch()
)
launchEnvironment["key"] = "value"
in the app:
ProcessInfo.processInfo.environment["key"]