Category "swiftui"

Sheet inside ForEach doesn't loop over items SwiftUI

I have an issue using a sheet inside a ForEach. Basically I have a List that shows many items in my array and an image that trigger the sheet. The problem is th

How to use fullScreenCover with iOS 14 but sheet for 13

Imagine you've built a screen that utilizes the sheet API to present modal sheets, and now with SwiftUI 2.0 you want to use fullScreenCover instead when run on

SwiftUI Dependency Injection

I have a SwiftUI app, its a tab based app struct Tab_View: View { var body: some View { TabView{ Main1_View().tabItem {

Can you get rid of opaque rectangle in a UIPickerView?

I'd like to remove this gray box in a UIPickerView. I'm trying to recreate this. If there is a way I'd greatly appreciate it. Here's the code snippet. I'm not

SwiftUI: dismiss List searchable keyboard?

I have a view that uses searchable. I would like do dismiss the keyboard programmatically if user starts scrolling on the List. Same behavior as you see in the

Button with double action (tap & long press) in SwiftUI

Is it possible in SwiftUI to set a button with an action on tap and a different action on long press ? I have tried this: Button(action: { self.handleButton

How to change PageTabView programmatically in iOS 14, SwiftUI 2?

I'm exploring new things came in Xcode 12 and SwiftUI 2.0 I have created a pageview onboarding screen with TabView and PageTabViewStyle in Xcode 12, iOS 14, Swi

SwiftUI | Using onDrag and onDrop to reorder Items within one single LazyGrid?

I was wondering if it is possible to use the View.onDrag and View.onDrop to add drag and drop reordering within one LazyGrid manually? Though I was able to make

SwiftUI - 2 Handle Range Slider

Is there a way, using SwiftUI, to create a Slider with 2 handles? I'm working on a project that that requires settings a low and high point for a random value t

SwiftUI app life cycle iOS14 where to put AppDelegate code?

Now that AppDelegate and SceneDelegate are removed from SwiftUI, where do I put the code that I used to have in SceneDelegate and AppDelegate, Firebase config

SwiftUI: Button with image got gray border on real iPhone but works fine on simulation mode

I'm trying to make simple app, the app seems working well on simulation mode, but test on my iPhone the button looks different from simulation iPhone, link the

In SwiftUI what is an easy way to align more than one view in ZStack

I have a view and I want to add two icons to it, at top right side and at bottom right side. I managed to do that: I used two ZStacks: ZStack(alignment: .botto

It is possible to hide this dots which is showing if I chose tabViewStyle(PageTabViewStyle())

It is possible to hide this dots which is showing if I chose tabViewStyle(PageTabViewStyle()). I don't found any result so im asking you guys.Its iPhone screen

SwiftUI conditionally rendering one view or another

struct ContentView: View { @EnvironmentObject var demoModel: DemoModel var body: some View { //this works demoModel.isLoggedIn ? Text("

.onReceive do not work when @Published property is changed [duplicate]

I have a @Published property in ViewModel and .onReceive in View. When my @Published var changes the .onReceive is not even executed. View is

SwiftUI: Animate offset to slide in from off screen

I'm trying to animate in a view the bottom of its parent view. This is relatively easy to do by animating the offset, like so: struct ContentView: View { @

Add border to only 1 button

I have a simple setup where I have 2 buttons and when a user clicks on one of them I want a border to show around it so that they know which one they clicked I

Expand SwiftUI button tap area over the button frame

I read a similar question about that issue. But that only expand the button size use .padding(). The red region in the snapshot is the tappable area. The trai

How to set a custom environment key in SwiftUI?

Creating a custom environment key works, but if I wish to set the value in a view, XCODE doesn't allow it. But the predefined environment values can be set. Wha

SwiftUI - how to copy text to clipboard?

How does one copy the contents of a Text field to the iOS clipboard? I have the following code & want to replace the "print(..)" statement with a statement