Perform accessibility audits for your app

RSS for tag

Discuss the WWDC23 Session Perform accessibility audits for your app

View Session

Posts under wwdc2023-10035 tag

2 Posts
Sort by:
Post not yet marked as solved
1 Replies
1.2k Views
0 I am adding a demo code here of my problem. For this I have created a parent view in which I have 2 child views, I have added "accessibilityElement(children: .combine)" code to the parent view, which combines all the elements while I tap on the view. but I want if the user tap on the parent view then the voiceover should speak all views but if the user taps on a button, then it should separately speak the button. Requirement: If the user taps on the parent view then it should speak all the elements of the view but if the user taps on the button then it should only speak the button, not the full view again. Demo Video link: https://drive.google.com/file/d/1aOuDoTiDizQstfEHiTy-8OoGqXcD_uk0/view?usp=sharing In this video, I want if the user taps on the button it should speak only button, not the full view again. The sample code: import SwiftUI struct ContentView: View { var body: some View { VStack(alignment: .leading, spacing: 10) { topView Button("Show details") { print("Tapped show detail") }.accessibilityElement() .accessibilityLabel(Text("This is show detail")) // I want if user tap on this button separatly then it should only speak the button lable only, not the full content again. bottomView }.accessibilityElement(children: .combine) // By this code it will read the topView, button, and bottomView .padding() } @ViewBuilder private var topView: some View { VStack(alignment: .leading, spacing: 5) { Text("First Text") Text("Second Text") } } @ViewBuilder private var bottomView: some View { VStack(alignment: .leading, spacing: 5) { Text("Third Text") Text("Fourth Text") } } } Requirement: If the user taps on the parent view then it should speak all the elements but if the user taps on the button then it should only speak the button, not the full view again.
Posted Last updated
.
Post not yet marked as solved
1 Replies
697 Views
I know this is far after the fact, but in going through the Widgets Code-along, part 2: Alternate timelines code-along, and having done very little SwiftUI, I ran into an issue that I can't seem to figure out. Things like this are one of the biggest reasons I haven't even considered migrating any of my apps to SwiftUI - I just can't get the UI to look the way I want it to. The code in question is very simple: Just a couple of things inside an HStack. For some reason, they added a ZStack around that (the HStack is the only thing inside it), and that ZStack changes the font size of one of the two HStack contents very slightly. For some reason. I'm really not sure why they bothered with the ZStack - it only has one thing inside it. Anyway, the code looks like this: HStack(alignment: .top) { AvatarView(entry.character) .foregroundColor(.white) Text(entry.character.bio) .padding() .foregroundColor(.white) } .padding() .widgetURL(entry.character.url) } .background(Color.gameBackground) .widgetURL(entry.character.url) And on the Panda hero (the only one Izzy demos), it looks fine. But The problem is with literally any other hero - they all have bios that are longer than Panda's, and they all clip their contents. If I put a background or a border on the Text(), it's very clear that while the left side (the AvatarView) takes up the whole height of the widget, the Text does not. That makes sense if its contents are small, but in most cases, the contents are substantially larger, and they clip, while leaving a bunch of blank space underneath. Obviously, that's just simply unacceptable from a UI perspective, and I haven't been able to figure out which of the modifiers I can put on Text will correct this - if any. I'm excited about the potential of SwiftUI to simplify what can often be huge storyboards, but things like this (******, little, should-be-easy things being effectively impossible) make me think that it's not worth the hassle. I did do web searches, including looking on StackOverflow, but what do you even search on for things like this? The terms I searched on, at least, bore no fruit. Thanks in advance for any help you can offer.
Posted Last updated
.