Customize CardinalKit Views (e.g. font or color) #35
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, you can, e.g., use the .font modifier to most of the CK views to change the font that is used in there like any other SwiftUI view 👍 A more general comment: If you want to increase the font size for the application and do that on a user-by-user basis, CK fully supports font scaling using the accessibility options. This is also how Apple generally recommends font scaling to work. You can do this like this: OnboardingView(
title: "WELCOME_TITLE".moduleLocalized,
subtitle: "WELCOME_SUBTITLE".moduleLocalized,
areas: [
.init(
icon: Image(systemName: "apps.iphone"),
title: "WELCOME_AREA1_TITLE".moduleLocalized,
description: "WELCOME_AREA1_DESCRIPTION".moduleLocalized
),
.init(
icon: Image(systemName: "shippingbox.fill"),
title: "WELCOME_AREA2_TITLE".moduleLocalized,
description: "WELCOME_AREA2_DESCRIPTION".moduleLocalized
),
.init(
icon: Image(systemName: "list.bullet.clipboard.fill"),
title: "WELCOME_AREA3_TITLE".moduleLocalized,
description: "WELCOME_AREA3_DESCRIPTION".moduleLocalized
)
],
actionText: "WELCOME_BUTTON".moduleLocalized,
action: {
onboardingSteps.append(.interestingModules)
}
)
.font(.title) Note the This results in the following view: If you want to further customize the views into a completely different style, you might need to recreate a few views or use more of the underlying views. E.g., you can customize this like this and use the individual onboarding views that you can provide: OnboardingView(
titleView: {
// .. your custom title view if you want to change that and modify that ...
Text("WELCOME_TITLE".moduleLocalized)
.font(.largeTitle.bold())
},
contentView: {
// An example on how to scale the text in the information view:
OnboardingInformationView(
areas: [/* ... */]
)
.font(.title)
},
actionView: {
OnboardingActionsView(
"WELCOME_BUTTON".moduleLocalized,
action: {
// ...
}
)
.font(.title2)
}
) These customizations do not only work for a font. E.g., you can change the accent color, other stylings, and all that SwiftUI provides you without configuration files or other mechanisms. We are good SwiftUI citizens and use all that information as much as possible. |
Beta Was this translation helpful? Give feedback.
Yes, you can, e.g., use the .font modifier to most of the CK views to change the font that is used in there like any other SwiftUI view 👍
A more general comment: If you want to increase the font size for the application and do that on a user-by-user basis, CK fully supports font scaling using the accessibility options. This is also how Apple generally recommends font scaling to work.
This is rather a system-wide accessibility setting rather than an app-by-app setting. We use the default font sizes, e,g., .body, in the framework. This is similar to how other frameworks that Apple develops and even ResearchKit does it.
You can learn more about fonts here: https://developer.apple.com/design/…