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
1
answer
87
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....
1
vote
0
answers
143
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("...
0
votes
1
answer
360
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 ...
0
votes
2
answers
418
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
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
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 ...
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("...
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
...
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
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: ...
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 ...
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 ...
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
vote
1
answer
527
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
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(
...
0
votes
0
answers
285
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, ...
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 ...
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 ...
-2
votes
1
answer
568
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
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.
/...
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 = ....
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 : {...
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 ...
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()...