Posts

Post not yet marked as solved
0 Replies
153 Views
I tried to narrow down the y-axis and use the clipped() to crop the excess. However, the clipped portion is too small, causing some of the chart to render above the x-axis. Is there any way to fix this, or any way to have the framework automatically set the y-axis range based on the data?
Posted
by zacJI.
Last updated
.
Post not yet marked as solved
1 Replies
225 Views
I'm trying to figure out how to build DocC from other frameworks to Xcode's Developer Documentation. I tried using the build documentation command, and it generates the DocC for my project and displays it in the Developer Documentation, but not libraries in the SPM. The code documentation does appear in the Developer Documentation, but the contents of the DocC are not shown.
Posted
by zacJI.
Last updated
.
Post not yet marked as solved
0 Replies
191 Views
I want to pass a value to a property marked with @State, and it doesn't work. struct AView: View { @State private var content: String? var body: some View { Text(content ? "") } init(content: String) { self.content = content } } #Preview { AView(content: "Test") } But if I change the content to non optional, it works well. struct AView: View { @State private var content: String var body: some View { Text(content) } init(content: String) { self.content = content } } #Preview { AView(content: "Test") } I googled for a while and found that I need to use a spacial way to initialize @State property in the first case. init(content: String) { _content = State(initialValue: content) } It works, but why? Is there any difficulty to unified API between optional and non optional @State property?
Posted
by zacJI.
Last updated
.
Post not yet marked as solved
0 Replies
182 Views
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.
Posted
by zacJI.
Last updated
.
Post not yet marked as solved
1 Replies
378 Views
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.
Posted
by zacJI.
Last updated
.
Post not yet marked as solved
0 Replies
260 Views
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 **** 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") } } } } } }
Posted
by zacJI.
Last updated
.
Post not yet marked as solved
1 Replies
244 Views
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 }
Posted
by zacJI.
Last updated
.
Post not yet marked as solved
2 Replies
287 Views
scrollClipDisabled seems only support ScrollView. I tried to add scrollClipDisabled to a Form but it did not work.
Posted
by zacJI.
Last updated
.