69 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
103
views
View modifier that displays content as a popover
I know this is somewhat of a strange thing to do, however because of our apps mix of SwiftUI and UIKit I have found myself writing views that on iPad are technically greedy but center a white ...
0
votes
1
answer
111
views
How do view modifiers like .font (which seem to change internal properties) work?
I am still struggling to understand how view modifiers work in SwiftUI.
As far as I know modifiers do not directly change the corresponding view but instead embed the view within a new view which ...
0
votes
0
answers
54
views
Why is ViewModifier's init method called multiple times?
I've created a custom navigation bar modifier CustomNavigationBarModifier in SwiftUI, which implements the ViewModifier protocol to standardize the navigation bar style throughout the app. However, I'...
0
votes
1
answer
123
views
How to access properties of underlying View in custom SwiftUI ViewModifier?
While trying to learn about how ViewModifiers can be used, I wonder if it possible to access the properties of the underlying view within the modifier:
For example, I would like to create an ....
1
vote
1
answer
153
views
SwiftUI: ViewModifier doesn't update when character limit is changed dynamically from outside
I am working on a SwiftUI project where I need to limit the number of characters a user can input in a TextField. I have implemented a custom ViewModifier to enforce this character limit. The limit is ...
-2
votes
1
answer
95
views
What else i can use in modifier( :) function except of ViewModifier protocol in SwiftUI?
I am new in SwiftUI, and now I am investigating ViewModifiers. All tutorials are very simple, just create new Struct, and body function + extension. But what does Apple say about it:
From developer....
0
votes
0
answers
104
views
What is the scope of SwiftUI onChange modifier?
I am confused by the onChange modifier behaviour inside NavigationStack with single EnvironmentObject.
I created this simple setup:
struct ContentView: View {
var body: some View {
...
0
votes
1
answer
394
views
How to style a view when used as a NavigationLink
struct Item: Identifiable {
let id = UUID()
let title: String
}
struct ContentView: View {
let items = [Item(title: "One"), Item(title: "Two"), Item(title: "...
2
votes
1
answer
205
views
SwiftUI .onAppear and ViewModifier (Progress) procedure. Why it is important?
I've make a custom ViewModifier like "Progress bar" (but in code below, for example, I use just different background color.
I have a function to download data from API (in code below, for ...
1
vote
1
answer
154
views
ViewModifier for DynamicViewContent?
I would like to do something like this:
struct HandleUrlDropModifier<Content>: ViewModifier where Content: DynamicViewContent {
@Environment(\.modelContext) var modelContext
var content:...
1
vote
1
answer
148
views
SwiftUI ViewModifier for contextMenu with generics
I want to add the iOS16 API for 'contextMenu forSelectionType: menu:', but I also need to support iOS15, so I need a conditional ViewModifier for this. I'm struggling with the correct syntax for it.
...
2
votes
2
answers
220
views
SwiftUI. Access custom view subviews from custom view modifier
I have a custom view:
public struct CustomView: View {
var text1: String
var text2: String
public var body: some View {
VStack {
Text(text1).tag(0)
Text(...
-1
votes
1
answer
243
views
Swift - Pass a parameter to a KeyPath
SwiftUI modifiers don't allow passing optional values, and I'd really like to handle them in a clean way. E.g.
struct MyView: View {
let accessibilityValue: String?
var body: some View {
...
0
votes
0
answers
217
views
SwiftUI: ViewModifier together with id() on a cell causes ScrollView performance issues
There is very poor performance when pulling scroll bar indicator to bottom and scrolling cells with big ordinal numbers. But if we comment empty ViewModifier applied to cell, everything became ok.
...
1
vote
2
answers
516
views
SwiftUI `ViewModifier` detect if `content` has `opacity` 0
I'm trying to write a custom ViewModifier where my implementation needs to detect if the content it is modifying is visible or not. This is not an ordinary ViewModifier where it's irrelevant if the ...