Post

Replies

Boosts

Views

Activity

Can not create a View with generic inside an other View
I tried to create a View with generic inside an other View, and it works fine with build and run. But when I tried to review it, Xcode 15.1 showed an error. CompileDylibError: Failed to build AView.swift Compiling failed: cannot find 'SubListView' in scope struct AView: View { struct BView<T: DisplayData>: View { } } I need to move the BView out of AView to fix the issues. I think it is a preview bug as it works well on build and run.
1
0
485
Dec ’23
SwiftUI: Change the button color in hover
I want to use the default button style, and I know we can set the tint to change the background color of a button. But how can I change the color when user hover the button, in macOS or tvOS? The hover button color is still a white with a transparency even it shows other color when not in hover.
1
0
2.2k
Dec ’23
Compare @FocusState will trigger change of it's value
I found a weird problem when I use @FocusState. I need to compare the value of @FocusState and display different View. But I found that compare @FocusState will trigger a change of it's value. The code blow will display two list of buttons. When you select the 2 button in the first list, the right button will display. When I try to move to the right button, the focus will jump to the 1 button in the first list. The reason is focused was changed to 1 when I try to jump to the right button(the value of focused will be nil and then 1). And if I remove the compare code(if focused == 2), it will work fine. I am currently using Xcode beta 6. Not sure if it is a bug in beta version. struct Demo: View { @FocusState var focused: Int? var body: some View { HStack { List { ForEach((1...10), id: \.self) { number in Button { } label: { Text("\(number)") } .focused($focused, equals: number) } } List { if focused == 2 { Button { } label: { Text("Button") } } } } } }
0
0
669
Aug ’23
scrollClipDisabled not support Form
Apple introduced a new API scrollClipDisabled to disable clip in List. But it dose not work in Form. What should I do if I want to disable the clip action and show the shadow? Or maybe scrollClipDisabled should support Form too? NavigationStack { Form { Section { Picker("播放速度", selection: $playSpeed) { ForEach(speeds, id: \.self) { speed in Text(String(speed)) } } Picker("最高画质", selection: $mediaQuality) { ForEach(MediaQualityEnum.allCases, id: \.self) { speed in Text(speed.desp) } } Toggle("Hevc优先", isOn: $preferHevc) Toggle("无损音频和杜比全景声", isOn: $losslessAudio) } header: { Text("播放器") } } .scrollClipDisabled() // not work }
1
0
688
Aug ’23
Can not create a View with generic inside an other View
I tried to create a View with generic inside an other View, and it works fine with build and run. But when I tried to review it, Xcode 15.1 showed an error. CompileDylibError: Failed to build AView.swift Compiling failed: cannot find 'SubListView' in scope struct AView: View { struct BView<T: DisplayData>: View { } } I need to move the BView out of AView to fix the issues. I think it is a preview bug as it works well on build and run.
Replies
1
Boosts
0
Views
485
Activity
Dec ’23
SwiftUI: Change the button color in hover
I want to use the default button style, and I know we can set the tint to change the background color of a button. But how can I change the color when user hover the button, in macOS or tvOS? The hover button color is still a white with a transparency even it shows other color when not in hover.
Replies
1
Boosts
0
Views
2.2k
Activity
Dec ’23
Compare @FocusState will trigger change of it's value
I found a weird problem when I use @FocusState. I need to compare the value of @FocusState and display different View. But I found that compare @FocusState will trigger a change of it's value. The code blow will display two list of buttons. When you select the 2 button in the first list, the right button will display. When I try to move to the right button, the focus will jump to the 1 button in the first list. The reason is focused was changed to 1 when I try to jump to the right button(the value of focused will be nil and then 1). And if I remove the compare code(if focused == 2), it will work fine. I am currently using Xcode beta 6. Not sure if it is a bug in beta version. struct Demo: View { @FocusState var focused: Int? var body: some View { HStack { List { ForEach((1...10), id: \.self) { number in Button { } label: { Text("\(number)") } .focused($focused, equals: number) } } List { if focused == 2 { Button { } label: { Text("Button") } } } } } }
Replies
0
Boosts
0
Views
669
Activity
Aug ’23
scrollClipDisabled not support Form
Apple introduced a new API scrollClipDisabled to disable clip in List. But it dose not work in Form. What should I do if I want to disable the clip action and show the shadow? Or maybe scrollClipDisabled should support Form too? NavigationStack { Form { Section { Picker("播放速度", selection: $playSpeed) { ForEach(speeds, id: \.self) { speed in Text(String(speed)) } } Picker("最高画质", selection: $mediaQuality) { ForEach(MediaQualityEnum.allCases, id: \.self) { speed in Text(speed.desp) } } Toggle("Hevc优先", isOn: $preferHevc) Toggle("无损音频和杜比全景声", isOn: $losslessAudio) } header: { Text("播放器") } } .scrollClipDisabled() // not work }
Replies
1
Boosts
0
Views
688
Activity
Aug ’23
scrollClipDisabled not support Form
scrollClipDisabled seems only support ScrollView. I tried to add scrollClipDisabled to a Form but it did not work.
Replies
2
Boosts
0
Views
688
Activity
Jul ’23