Reputation: 139
In swiftUI how to move focus to required view. After click on one button api is getting called and view is refreshing, but after that focus is moving back to top left corner of view. i want that focus to stay on same button.
Upvotes: 3
Views: 2262
Reputation: 2061
When you want to switch the focus, you have to hide focus for one view and unhide the focus for required view.
You can use below modifier
in SwiftUI
for focus switch which is available to support from iOS 13
.accessibility(hidden: true/false)
Upvotes: 0
Reputation: 1142
Unfortunately SwiftUI does not support focus state in iOS less than 15. You can use their API which is supported in IOS 15 only. The other option will be to use UIKit based component and manage focus but this will be lot of work depending on your UI design and components.
Upvotes: 0