72 questions
1
vote
1
answer
77
views
How to make SwiftUI Widget buttons fill their container height when using GeometryReader with calculated row heights?
I'm building an iOS Widget (WidgetKit) with a 2×2 button grid using GeometryReader to calculate row heights. The buttons should fill their
containers completely and have equal heights, like Apple's ...
0
votes
3
answers
2k
views
How to make a Liquid Glass Next button as a Circle?
I'm trying to create a Next button (as a right chevron) in the toolbar that looks identical to the iOS 26 back button (with the left chevron) in the new Liquid Glass style. But all my solutions ...
0
votes
1
answer
85
views
How to make a Button work inside a ScrollView but outside of the ScrollView's bounds in SwiftUI?
I observed a weird behavior and I believe it's a bug in SwiftUI but maybe it's not or someone knows a way to fix it.
By default, overlays have the same size as the view they are attached to in SwiftUI....
0
votes
0
answers
50
views
SwiftUI Button in List works only with press+slide rather than tap
When checking a checkbox Button in List:
Click/tap events don't trigger the expected response
The associated action button only activates with a press+slide
What could be causing this interaction ...
1
vote
0
answers
142
views
No tap animation when pressing a Button inside a ScrollView with SwiftUI
I am writing an application and have a structure similar to the following:
ScrollView {
VStack {
Button(action: {
print("hello")
}) {
Text("...
1
vote
1
answer
132
views
Connecting a button to .searchable modifier
I have an app with SampleData of country names displayed in a list with the searchable modifier. I also have button on the bottom right of the screen. This is all within the NavigationStack:
...
0
votes
1
answer
359
views
Reduce text and background opacity when Button is disabled
I am learning SwiftUI and currently building a custom button. What I am trying to achieve is, when the button is disabled its opacity should be 0.5 but not the title. The title opacity should be 0.9 ...
-1
votes
1
answer
81
views
Button appears to have an inner and outer area with different actions, how can I make sure only one action is used for both tappable areas
Snapshot of Code and Preview in Xcode
Attached is an image with the button and code for reference. Here's also the code in case you'd like to test this out yourself:
struct ContentView: View {
var ...
0
votes
2
answers
417
views
Text disappears in dark mode when tinting borderedprominent button
The button text does not change colors properly when switching between light and dark mode. In light mode it shows up as a black button with white text. in dark mode it just shows a white button with ...
0
votes
2
answers
161
views
Rounded button background box color
I'd like to make the. box surrounding my rounded button match the background but it's darkened. I would also like to eliminate the dark circle below the button, which looks like it must be generated ...
0
votes
1
answer
39
views
Why is "toggle()" function not producing the same result as explicitly writing out a toggle?
The following block works:
Main File
import SwiftUI
struct Home: View {
@State private var ToDoItems: [ToDoItem] = [ToDoItem(title: "Task", description: "Need to do", urgent: ...
2
votes
1
answer
120
views
Can’t make a button tappable parallel to navigationTitle
The button is not tappable as I move it to the extended line of the title. If I move it to somewhere else, it works but I want to place it on the line of Title.
But whenever I do it, it does not ...
2
votes
0
answers
108
views
SwiftUI Button ListRowBackgroundColor doesn't Change
I'm attempting to recreate a button that simulates the behavior of a NavigationLink inside a List in SwiftUI. However, when tapping the button wrapped inside the List, the listRowBackground color ...
0
votes
2
answers
149
views
How do I make my text navigate me to a subpage?
I have the text "Groups" and I want to use NavigationLink to connect it to my GroupsPage subpage and take the user there when they click the Groups text.
Edit: This is how it looks with the ...
1
vote
1
answer
181
views
How can i get animation when click a button that in List?
My code is like this:
List {
Button(action: {}, label: {
Text("Button")
})
Button(action: {}, label: {
Text("...
1
vote
1
answer
769
views
SwiftUI: Long Press fills button to show progress?
I pieced together this code for a watch app and it kind of works but it's not perfect. (1) The fill does not match exactly, it starts outside the bounds of the buttons view but I can't figure out how ...
0
votes
0
answers
40
views
screen not navigating to other screen based on conditions, on button click
I want to navigate to ChatScreen() based on conditions, when click on right group, print statement is showing "group found" but its not navigating:
List(viewModel.danceGroups) { group in
...
0
votes
2
answers
116
views
Using sheet for presenting different views on 2 buttons actions are presenting view incorrect view
enum ActiveSheet: Identifiable {
case first, second
var id: Int {
return hashValue
}
}
struct ContentView: View {
@State var activeSheet: ActiveSheet?
var body: some ...
2
votes
1
answer
2k
views
Prevent that multiple buttons can be pressed simultaneously in SwiftUI
I have a SwiftUI app with a complex dashboard view consisting of several other nested custom SwiftUI views containing SwiftUI buttons.
I want to prevent that these different buttons can be pressed ...
0
votes
1
answer
325
views
How to animate a swiftUI button to display another view
I have a quite simple case, a view displays another one when a button is pressed.
The label on the second view is at the top of the view, which is working fine, unless I try to animate the button when ...
0
votes
0
answers
858
views
SwiftUI Button animation
I use ButtonStyle, for button style. But when I updated button from enable to disable, and change thread, the button change without animation.
//I have ButtonStyle:
struct WizardButtonStyle: ...
1
vote
1
answer
579
views
SwiftUI: Button is clickable outside its frame
I am making log in button for log in page. I have this problem: outside (below, right or left) of the button area, button still gets clicked.
How I fix this?
I want this button to get clicked when I ...
3
votes
2
answers
4k
views
No tap animation when clicking a Button inside a Form in SwiftUI
I am using a Form in SwiftUI based on a tutorial from YouTube, and I have placed some components inside it. However, when I tap the button, it doesn't show the tap animation (For example, when I tap a ...
0
votes
1
answer
812
views
SwiftUI dynamic list of Button
I created a view showing a list of Button. These buttons are displaying a date. This view is instantiated in my HomeView.
My need is that whenever the user taps one of the button, the date displayed ...
3
votes
1
answer
5k
views
How can you add clickable text in a SwiftUI Text() View?
I've seen people using AttributedString and .link to link to something, but I need it to run a function, not open a browser link. I want something like this in SwiftUI, with wrapping, etc.
Terms of ...
1
vote
2
answers
632
views
SwiftUI Button background color showing over text
For some reason my background is showing over my text label. I have the background as white and text as red, but for some reason the white background covers the text. I am referring to the "Tap ...
3
votes
4
answers
4k
views
SwiftUI State in Preview with PreviewProvider is not working
I've a simple button that work on simulator as expected, the shape changes with click;
struct ButtonTest: View {
@State var isLiked = true
var body: some View {
VStack {
...
-1
votes
1
answer
256
views
I can't dynamically add items to List. SwiftUI
I can't dynamically add items to List. SwiftUI.
import SwiftUI
struct UpdateList : View {
var updates = updateData
@ObservedObject var store = UpdateStore(updates: updateData)
**Update func ...
1
vote
1
answer
526
views
How to transition to a new view in swiftui
My goal is to have the user click a button that then gives them a choice of yes or cancel, this works fine. Is yes is selected it should move to the Camera View. I am getting the error: Result of '...
0
votes
1
answer
670
views
SwiftUI Buttons meant to increment or decrement score, does so with the value of OTHER buttons almost exclusively
I have five buttons in swiftUI, that are meant to increase or decrease a displayed score, based on the response to an alert with two options, triggered on button press.
When pressing the button ...
0
votes
1
answer
146
views
Display curved button with custom color
I am trying to achieve a Scrollview with buttons that have rounded corners and a custom color.
Button(shoppingListItem.text) {
removeFromShoppingList(itemId: shoppingListItem.item_id)
}
.overlay(
...
2
votes
1
answer
2k
views
SwiftUI - Combine buttonStyle functionality with different functions for each button
I am new to SwiftUI and iOS. What I am trying to achieve is to add a buttonStyle to all the buttons inside my app, while keeping the function that each button calls when pressed. This is my code so ...
0
votes
0
answers
282
views
Coding a SwiftUI button to trigger a Menu item
I am trying to design a button in swiftUI that will call 1 of the built in menu items (mac only). I know how to replace built in menu item & force it to share the same functionality with a button, ...
4
votes
2
answers
8k
views
How to make a custom DisclosureGroup (drop down) in SwiftUI?
I want to make a custom DisclosureGroup that has the same functionality as the default DisclosureGroup but allows me to change the color text or even put an image instead of a string.
Because ...
2
votes
1
answer
161
views
How do I persist the button color after favoriting in SwiftUI?
I would like my favorites button to switch colors based on if the user favorites or unfavorites a character. I am able to change the text from "Favorite" to "Favorited" and change ...
3
votes
0
answers
2k
views
SiwftUI nested buttons, child tap triggers parent animation
I have been looking around but couldn't find the solution so lets hope someone can help me.
I have a ScrollView with a LazyVStack in it. Then I have a list of 'cells'.
Simplified it looks something ...
0
votes
1
answer
192
views
How do I make buttons lead to other buttons in SwiftUI?
My code currently shows two buttons next to each other, one button being countries and the other being states. I want to make it so that once a button is pressed, a new set of buttons will appear. For ...
0
votes
1
answer
358
views
How to determine width needed for a button in SwiftUI
If I have a string that I will place inside of a SwiftUI button label, how can I determine how much width I need to allow the button to consume such that the text in the button will not be truncated ...
-2
votes
1
answer
567
views
Filter List as per Date in Swiftui
Displaying a list from API. I want to show list based on date. There are three buttons in my view : Previous Day, Last Three Days, and a button providing calendar to chose dates.(Havent implemented ...
0
votes
1
answer
931
views
How to uniquely get Button if I extract as a subview in SwiftUI
So I am making a simple restaurant bill splitting app and I have a button that I want to highlight when the user clicks on it. I also want the other buttons to be not highlighted. In UIKit it would be ...
0
votes
0
answers
119
views
Is it exist better way to emplement lock/unlock button with swiftui?
I tried to implement lock/unlock button, but it was hard to make.
In my case, I used two Image. One is Rectangle with a lock, another is just a rectangle.
And using ZStack, made them as a one button.
/...
3
votes
2
answers
956
views
Button is not Taking Given Height and Width in SwiftUI
I am new to swiftui. I am making a login screen in which I have to use log in with apple and gmail buttons. I am using a custom view to design the button. Here is the code for that custom button view:
...
0
votes
2
answers
1k
views
How can I add two images (one at the left and one on the right side) in a button in Xcode programaticly? I need also a title of a button
func setupButtonUI() {
if let detailsImage = UIImage(named: "detalji_icon") {
setImage(detailsImage, for: .normal)
contentHorizontalAlignment = .left
contentVerticalAlignment = ....
0
votes
1
answer
697
views
SwiftUI Mac: Adding buttonStyle Makes Button Click Propagate to Parent
I am trying to create a situation in a SwiftUI Mac app where when I click a Button inside a parent view, only the Button's action is trigger—not any of the tap gestures attached to its parent.
Here is ...
1
vote
1
answer
1k
views
SwiftUI sheet presenting on tapping anywhere
I have created a @StateObject from where a Login page is presented:
@StateObject var loginViewModel = //LoginViewModel Name
and There is a Button inside Vstack like this
VStack{
Button(action : {...
3
votes
1
answer
792
views
Is there a way to set font tracking (i.e. spacing) inside a custom SwiftUI ButtonStyle?
In SwiftUI you can set font tracking (spacing between letters) on a Text View using the tracking View modifier:
Text("Hello, World!")
.tracking(10)
If you have a Button and apply your ...
0
votes
2
answers
2k
views
SwiftUI - Button inside a custom Collection view is not tappable completely
I have a set of buttons to show for the user and I used CollectionView to align the buttons. Each button is a Vstack with an Image and Text components. The tap is reactive only on the image but not on ...
0
votes
1
answer
657
views
How to set up Textfield and Button in Custom SwiftUI View
I am attempting the configure the text field and button in my openweathermap app to be in its own view other than the main content view. In TextFieldView, the action of the button is set up to call an ...
1
vote
0
answers
185
views
Confusing button-actions in SwiftUI
Here is some SwiftUI code in a running app I am working on:
Button(action: action) {
Image(systemName: img)
.imageScale(.large)
}
.simultaneousGesture(LongPressGesture()...
2
votes
0
answers
274
views
How to get a button's default background color when pressed?
How do I get the default highlighted color of a Button?
For example, when I tap the button rendered by the code below, the row background color turns light gray, specifically red: 209, green: 209, and ...