init
This commit is contained in:
commit
acc61e858b
18 changed files with 5068 additions and 0 deletions
68
ios/recipies.md
Normal file
68
ios/recipies.md
Normal file
|
@ -0,0 +1,68 @@
|
|||
---
|
||||
layout: default
|
||||
title: Recipies
|
||||
categories: swift
|
||||
---
|
||||
|
||||
```swift
|
||||
|
||||
extension UIFont {
|
||||
var bold: UIFont {
|
||||
guard let newDescriptor = fontDescriptor.withSymbolicTraits(.traitBold) else {
|
||||
return self
|
||||
}
|
||||
return UIFont(descriptor: newDescriptor, size: pointSize)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```swift
|
||||
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
|
||||
|
||||
```swift
|
||||
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()`)
|
||||
|
||||
```swift
|
||||
launchEnvironment["key"] = "value"
|
||||
```
|
||||
|
||||
in the app:
|
||||
|
||||
```swift
|
||||
ProcessInfo.processInfo.environment["key"]
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue