Does SwiftUI 2.0 Text support "justify" multiline text alignment.
And if not, is there a way, without using UIKit, to achieve 'justified' alignment?
Unfortunately, we still don't have alignment type as justified in SwiftUI. You have to use UIKIT with UIViewRepresentable
Related
I want to add character spacing in the text of SwiftUI in iOS version iOS 14 and plus.
When I use a new modifier called as kerning and Tracking after applying fonts styling then it won't work. So any pointer will be appreciated.
kerning and tracking are available in earlier versions of iOS, but only if they're applied directly to Text views.
What's new in iOS 16 is the ability to apply the modifier to any view, and have it apply to any of its Text child views.
Note the iOS availability flags:
Text.tracking(_:) - iOS 13.0+
View.tracking(_:) - iOS 16.0+
So that means that this should work for you in iOS 14:
Text("My Sample Text")
.tracking(-0.1)
but this would not:
VStack {
Text("My Sample View")
Text("With two lines of text")
}
.tracking(-0.1)
I have a specific view in my application where I need the status bar to be white (dark mode).
I've tried setting the .preferredColorScheme(.dark) but as the documentation mentions, that affects all the views in my window which is not what I'm looking for.
I've taken a look at this but it seems to be done using SceneDelgate which I am not making use of.
Is there any workaround to this?
For iOS 16, you can set .toolbarColorScheme for a specific View. Unfortunately, this is not supported on older iOS Versions. As a workaround that does not involve SceneDelegate, you could manipulate UIToolBar.appearance() directly with a new tint color. This has nothing to do with the preferred color scheme (e.g., light or dark mode), but could have the same effect.
How to detect number of finger interaction with Gesture in SwiftUI Gesture. With UIKit we can find number of find it from
let numberOfTouches = panGestureRecognizer.numberOfTouches
Any thought?
I am able to find my solution using UIKit UIView. Actually made container view(UIVIewRepresentable) which implements the PanGesture. I have used this view to to hold SwiftUI view. I can easily find and able to handle Panning behaviour.
I'm specifically interested in electricField() and magneticField().
Is there any similar SwiftUI library?
I've been using SwiftUI on this simple WidgetKit (iOS 14) successfully, until I added a dark mode asset (PDF) to the image:
If I choose, under "appearance" on the right, "Any, Dark", the widget crashes. I thought SwiftUI would handle this gracefully... Is there a "proper" way to take advantage of the image set's appearances, or do I have to do write the logic to choose between 2 image sets?