Post

Replies

Boosts

Views

Activity

Different shades or overlays in form elements
I'm stuck with some UI-work in my macOS app, currently designing form elements. I am trying to stay in SwiftUI, but I guess running to the limits of it. All my input elements should have the same background color (see image, #1) In the DatePicker() I managed to set the background color and crop it with  .background(                 RoundedRectangle(cornerRadius: 10)                     .fill(Color.myBackgroundColor)             ) but it still has a slightly different color in the text field (around the arrows it's correct, where I marked it with 2 it is a litte bit brighter) Even worse is the picker (3): The color is set to the same value, but some overlay makes it way brighter. My modifier looks like this: .background(Color.myBackgroundColor)             .cornerRadius(10)             .overlay(                    RoundedRectangle(cornerRadius: 10)                        .stroke(Color.myBorderColor, lineWidth: 1)                ) Also, is there a way to change the blue of the picker (4)? Probably I need to find a similar solution like in the TextEditor() where I used this: extension NSTextView {     open override var frame: CGRect {         didSet {             backgroundColor = .clear //<<here clear             drawsBackground = true         }     } }
1
0
378
Dec ’21
SwiftUI popover disappearing when focus changes to its elements on some devices
I have a weird problem using a popover - this behavior is pretty random to me so I somehow think it's a bug - but I cannot reproduce the problem in a smaller project to give you reproducible code. I'm showing a table with a few rows and columns, one of this items per row is editable. If the user taps on the button a popover does appear, presenting a View with a TextField or a TextEditor (tried both with the same result). It all works fine on the iPhone (any situation), it works on the iPad in horizontal format, it works on the iPad in vertical format if there is an external keyboard connected. But - as soon as iOS needs to show the on screen keyboard, the popover disappears and so does the keyboard again. I replaced the popover view with a simplified version, to make sure there is nothing wrong with the popoverView and still got the same behavior. struct SimpleRemarkPopover: View {     @Binding var showPopover:Bool     @State var comment:String     var body: some View {         TextEditor(text: $comment)         Button(action: {             showPopover = false         }, label: {             Text("Hide Popover")         })     } } The Button showing the popover is also not too complex, nothing special there: Button(action: { showPopover = true }, label: { Image(systemName: "square.and.pencil") }) .popover(isPresented: $showPopover) { SimpleRemarkPopover(showPopover: $showPopover, comment: item.comment ?? "") } Except a ScrollView, as ScrollViewReader and a GeometryReader there are no other Elements used except ZStack, HStack and VStack - so actually nothing fancy. All data to fill the table comes from a ObservableObject Did anyone experience similar problems, any known bugs or workarounds for this problem? For a few days I'm trying to get the same result on my test-project, but can't - which is pretty annoying.
2
3
2.4k
Feb ’23