mathstodon.xyz is one of the many independent Mastodon servers you can use to participate in the fediverse.
A Mastodon instance for maths people. We have LaTeX rendering in the web interface!

Server stats:

2.8K
active users

#swiftui

27 posts25 participants1 post today

Starting with iOS 17, foregroundStyle(_:) in #SwiftUI can be used to style fragments of text inside a string. When applied directly to a Text instance, the modifier returns a Text instead of some View, which allows us to use it inside text interpolation: nilcoalescing.com/blog/Foregro

Nil CoalescingInterpolate text with custom foreground style in SwiftUIAdd custom foreground styles, such as gradients, to words inside Text views in SwiftUI.

A ViewModel is a very specific concept. If you think you need a ViewModel in #SwiftUI (probably not necessary because SwiftUI has formatters like AppKit), I'm pretty sure it should be a struct (representing the projection of the actual model to the values required by the View).
Not, ever, a StateObject.

If any Boston-area #CircuitPython friends would like to come out to Boston College Arts Fest, Sat. April 26, my students are presenting 1-3pm both Physical Computing & #SwiftUI projects in the new MakerSpace building 245 Beacon St. Room 301. No pressure, but would love to see you there if interested & able! @blitzcitydiy @ecken @danhalbert. All welcome! bc.edu/content/bc-web/sites/bc

Boston CollegeArts Festival 2025Boston College's annual celebration of the arts takes place April 24–26

I’ve got so many mastodon posts bookmarked, I’ve been trying to find a why to manage them all. So I’ve started building a little iOS app which will let the user tag the bookmarks and also add them to folders.

Cue the influx of people telling me there is ways to do that already 😅

If anyone has any ideas for other handy features, I’m all ears.

When displaying a custom image in SwiftUI, if the image name is included in a string catalog or Localizable.strings, SwiftUI will automatically apply the localized string as the accessibility label, with no need for the accessibilityLabel() modifier. #iOSDev #SwiftUI
nilcoalescing.com/blog/ImageAc

Nil CoalescingAutomatic image accessibility labels from localized strings in SwiftUISwiftUI uses a localized string matching the image name as the accessibility label, without needing to apply the accessibilityLabel() modifier.

A simple thing that I do all the time in SwiftUI: apply a .border(.red, width: 1.0) to views to make sure the layout meets my expectations. If there are several views, I use different colors. Sometimes, this reveals interesting situations.

macOS: Applying vertical .fixedSize to Text adds huge margins above and below for no apparent reason

Apple folks: FB17238588

Is there any other way that actually works of avoiding cropping text in SwiftUI on macOS? .lineLimit(nil) is not included in the "actually works" bag of solutions. The only way I can fix this is wrapping everything in a ScrollView but that is obviously not ideal.

SwiftUI includes several ways to change the color of text, including foregroundStyle(), tint(), AttributedString, and textRenderer() for advanced cases. My new blog post walks through how they work and which approach to choose for different use cases: nilcoalescing.com/blog/Foregro
#SwiftUI #iOSDev

Nil CoalescingWays to customize text color in SwiftUISwiftUI offers several methods to change the color of text, including foregroundStyle() and tint() modifiers, AttributedString attributes, and the textRenderer() API for advanced styling.

Second #SwiftUI mid-term is in progress. Students have 2.5 hrs to build two apps: SwiftData “ESSI - the Emotional Support Snack Inventory app” and “D&D Monsters” a URLSession API call JSON parsing app. Want talent? Send me your job calls and I’ll pass on to them. Even better! All are welcome to the Student Tech Showcase, Sat April 26, 1-3pm, Boston College bldg 245 Beacon St room 301. Hope to see you there! (1/2)