Skip to content

Commit 37269a4

Browse files
committed
Support Mac & MacCatalyst
1 parent 7711cb8 commit 37269a4

5 files changed

Lines changed: 42 additions & 6 deletions

File tree

Examples/CustomNavigationTitleExample/CustomNavigationTitleExample.xcodeproj/project.pbxproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@
262262
CURRENT_PROJECT_VERSION = 1;
263263
DEVELOPMENT_ASSET_PATHS = "\"CustomNavigationTitleExample/Preview Content\"";
264264
DEVELOPMENT_TEAM = 3R64T2FHGY;
265+
ENABLE_APP_SANDBOX = YES;
266+
ENABLE_HARDENED_RUNTIME = YES;
267+
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
265268
ENABLE_PREVIEWS = YES;
266269
GENERATE_INFOPLIST_FILE = YES;
267270
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
@@ -274,9 +277,13 @@
274277
"$(inherited)",
275278
"@executable_path/Frameworks",
276279
);
280+
MACOSX_DEPLOYMENT_TARGET = 13.0;
277281
MARKETING_VERSION = 1.0;
278282
PRODUCT_BUNDLE_IDENTIFIER = com.2500Chronos.CustomNavigation.CustomNavigationTitleExample;
279283
PRODUCT_NAME = "$(TARGET_NAME)";
284+
REGISTER_APP_GROUPS = YES;
285+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
286+
SUPPORTS_MACCATALYST = NO;
280287
SWIFT_EMIT_LOC_STRINGS = YES;
281288
SWIFT_VERSION = 5.0;
282289
TARGETED_DEVICE_FAMILY = "1,2";
@@ -292,6 +299,9 @@
292299
CURRENT_PROJECT_VERSION = 1;
293300
DEVELOPMENT_ASSET_PATHS = "\"CustomNavigationTitleExample/Preview Content\"";
294301
DEVELOPMENT_TEAM = 3R64T2FHGY;
302+
ENABLE_APP_SANDBOX = YES;
303+
ENABLE_HARDENED_RUNTIME = YES;
304+
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
295305
ENABLE_PREVIEWS = YES;
296306
GENERATE_INFOPLIST_FILE = YES;
297307
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
@@ -304,9 +314,13 @@
304314
"$(inherited)",
305315
"@executable_path/Frameworks",
306316
);
317+
MACOSX_DEPLOYMENT_TARGET = 13.0;
307318
MARKETING_VERSION = 1.0;
308319
PRODUCT_BUNDLE_IDENTIFIER = com.2500Chronos.CustomNavigation.CustomNavigationTitleExample;
309320
PRODUCT_NAME = "$(TARGET_NAME)";
321+
REGISTER_APP_GROUPS = YES;
322+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
323+
SUPPORTS_MACCATALYST = NO;
310324
SWIFT_EMIT_LOC_STRINGS = YES;
311325
SWIFT_VERSION = 5.0;
312326
TARGETED_DEVICE_FAMILY = "1,2";

Examples/CustomNavigationTitleExample/CustomNavigationTitleExample/ContentView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ struct ContentView: View {
4242
section2
4343
}
4444
}
45+
#if canImport(UIKit)
4546
.listStyle(.insetGrouped)
47+
#endif
4648
.scrollAwareTitle("Privacy & Security")
4749
.navigationTitle("Hello!")
4850
}

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import PackageDescription
66
let package = Package(
77
name: "CustomNavigationTitle",
88
platforms: [
9-
.iOS(.v16)
9+
.iOS(.v16), .macCatalyst(.v16), .macOS(.v13)
1010
],
1111
products: [
1212
// Products define the executables and libraries a package produces, making them visible to other packages.

Sources/CustomNavigationTitle/CustomNavigationTitle.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#if os(iOS)
2-
31
import SwiftUI
42

53
struct BoundsPreferenceKey: PreferenceKey {
@@ -42,7 +40,6 @@ private struct ScrollAwareTitleModifier<V: View>: ViewModifier {
4240
return Color.clear
4341
}
4442
}
45-
.navigationBarTitleDisplayMode(.inline)
4643
.toolbar {
4744
ToolbarItem(placement: .principal) {
4845
title
@@ -51,7 +48,19 @@ private struct ScrollAwareTitleModifier<V: View>: ViewModifier {
5148
.opacity(isShowNavigationTitle ? 1 : 0)
5249
.animation(animation, value: isShowNavigationTitle)
5350
}
51+
#if compiler(>=6.2)
52+
.modifier{
53+
if #available(iOS 26.0, macOS 26.0, macCatalyst 26.0, *) {
54+
$0.sharedBackgroundVisibility(.hidden)
55+
} else {
56+
$0
57+
}
58+
}
59+
#endif
5460
}
61+
#if canImport(UIKit)
62+
.navigationBarTitleDisplayMode(.inline)
63+
#endif
5564
}
5665
}
5766

@@ -73,5 +82,3 @@ extension View {
7382
}
7483
}
7584
}
76-
77-
#endif
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import SwiftUI
2+
3+
extension View {
4+
func modifier(@ViewBuilder _ closure: (Self) -> some View) -> some View {
5+
closure(self)
6+
}
7+
}
8+
9+
extension ToolbarContent {
10+
func modifier(@ToolbarContentBuilder _ closure: (Self) -> some ToolbarContent) -> some ToolbarContent {
11+
closure(self)
12+
}
13+
}

0 commit comments

Comments
 (0)