Post

Replies

Boosts

Views

Activity

Reply to HStack TextFields
There's no way to show it because SwiftUI won't allow it. Do you see the white space between the yellow and green? I don't want that. I want there to be gray in between them. Similar to the way they would be if they were stacked vertically:
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to SwiftUI and @FetchRequest - modify predicate or sort dynamically?
After two years I have the solution you are looking for, but you probably don't need it anymore, but for others who may also be wondering the same thing here is an example of how to sort a FetchedResults type with a search bar You'll ned to include this at the top of your struct. and you have to change "Item" to the name of the entity in your core data file. @FetchRequest(sortDescriptors: []) var items: FetchedResults<Item> @State private var searchingFor = "" And link this to the end of your list or whatever contains your list. You'll have to change title to whatever the name of your attribute is in your core data file .searchable(text: $searchingFor, placement: .navigationBarDrawer(displayMode: .always), prompt: "Search Titles") .onChange(of: searchingFor){ value in if (searchingFor != ""){ items.nsPredicate=NSPredicate(format: "title CONTAINS[c] %@", searchingFor) } else { items.nsPredicate=nil } Let me know if you have any questions!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to Allowing taps only in vstack deep links within a HStack in widget
In iOS 14 and later, widgets are interactive by default, which means users can tap on any part of the widget to launch the associated app or perform some action. However, if you want to make certain parts of the widget non-tappable, you can use the .background(_:) modifier with a clear color to disable hit testing on those areas. Here's how you can modify your code to make only the VStacks within the HStack tappable: struct ThreeContactWidgetView: View { var entry: Provider.Entry var body: some View { HStack(spacing: 12) { Spacer() ForEach(contacts.prefix(3)) { contact in Link(destination: URL(string: "myApp://call?contactId=\(contact.identifier)")!) { VStack { Image(systemName: "person.crop.circle.fill") .resizable() .aspectRatio(contentMode: .fit) .clipShape(Circle()) Text("\((contact.givenName))") .font(.headline) .padding(.top, 4) } .frame(width: 100) } .background(Color.clear) // Disable hit testing on this area } Spacer() } .padding() .containerBackground(for: .widget) {} } } By adding .background(Color.clear) to each Link's VStack, you should prevent tap gestures from being recognized on the Spacer areas and only allow taps on the VStacks, which will trigger the associated deep links for the respective contacts.
Topic: App & System Services SubTopic: General Tags:
Oct ’23