Skip to content

Commit 6778fc3

Browse files
authored
Use native lineHeight on 26.0+ systems (#154)
* Use native lineHeight viewModifier on iOS 26 * Use latest macOS * Update changelog * Update Xcode version
1 parent 491c5d6 commit 6778fc3

6 files changed

Lines changed: 22 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ on:
66
branches:
77
- main
88

9+
env:
10+
DEVELOPER_DIR: /Applications/Xcode_26.1.1.app/Contents/Developer
11+
912
jobs:
1013
carthage:
1114
name: Carthage
12-
runs-on: macos-15
15+
runs-on: macos-latest
1316
steps:
1417
- uses: actions/checkout@v4
1518
- name: Build
@@ -22,7 +25,7 @@ jobs:
2225
${{ runner.os }}-carthage-
2326
spm:
2427
name: SPM
25-
runs-on: macos-15
28+
runs-on: macos-latest
2629
steps:
2730
- uses: actions/checkout@v4
2831
- name: Build

.github/workflows/docbuild.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ concurrency:
1414
group: "pages"
1515
cancel-in-progress: true
1616

17+
env:
18+
DEVELOPER_DIR: /Applications/Xcode_26.1.1.app/Contents/Developer
19+
1720
jobs:
1821
# Single deploy job since we're just deploying
1922
deploy:
2023
environment:
2124
# Must be set to this for deploying to GitHub Pages
2225
name: github-pages
2326
url: ${{ steps.deployment.outputs.page_url }}
24-
runs-on: macos-15
27+
runs-on: macos-latest
2528
steps:
2629
- name: Checkout 🛎️
2730
uses: actions/checkout@v4

.github/workflows/tests.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ name: Tests
22

33
on: [workflow_call]
44

5+
env:
6+
DEVELOPER_DIR: /Applications/Xcode_26.1.1.app/Contents/Developer
7+
58
jobs:
69
xcodebuild:
710
name: Xcodebuild
8-
runs-on: macos-15
11+
runs-on: macos-latest
912
env:
1013
IOS_DEVICE: iPhone 16 Pro
1114
steps:
@@ -47,7 +50,7 @@ jobs:
4750
path: Tests-tvOS.xcresult
4851
spm:
4952
name: SPM
50-
runs-on: macos-15
53+
runs-on: macos-latest
5154
steps:
5255
- uses: actions/checkout@v4
5356
- name: SPM build

.github/xcode-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
## Next
1010

11+
- Update `font(_:lineHeight:textStyle:)` viewModifier to use native [`lineHeight`](https://developer.apple.com/documentation/swiftui/environmentvalues/lineheight) on +26.0 systems ([#154](https://github.com/AckeeCZ/ACKategories/pull/154), kudos to @olejnjak)
12+
1113
## 6.16.0
1214

1315
- Add SwiftUI extension `View+FrameSize` ([#153](https://github.com/AckeeCZ/ACKategories/pull/153), kudos to @lukashromadnik)

Sources/ACKategories/SwiftUIExtensions/FontModifier.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public extension View {
1010
/// - font: The font to use in this view.
1111
/// - lineHeight: The line height to use in this view.
1212
/// - textStyle: The text style for relative font scaling. If `nil`is specified then dynamic type is turned off.
13+
///
14+
/// On iOS 26 and above uses native [lineHeight](https://developer.apple.com/documentation/swiftui/environmentvalues/lineheight) view modifier.
1315
@ViewBuilder func font(
1416
_ font: UIFont,
1517
lineHeight: Double?,
@@ -19,7 +21,10 @@ public extension View {
1921
let customFont = textStyle
2022
.map { Font.custom(font.fontName, size: font.pointSize, relativeTo: $0) } ?? Font(font)
2123

22-
if let lineHeight {
24+
if #available(iOS 26.0, tvOS 26.0, watchOS 26.0, *), let lineHeight {
25+
self.font(customFont)
26+
.lineHeight(.exact(points: lineHeight))
27+
} else if let lineHeight {
2328
self.font(customFont)
2429
.lineSpacing(lineHeight - font.lineHeight)
2530
.padding(.vertical, (lineHeight - font.lineHeight) / 2)

0 commit comments

Comments
 (0)