I have ViewController where I want retrieve control through the focus engine. Firstly I tried to just fire up by asking view it self.
if settingsFilterSegment.isFocused {}
But I am getting false, so I tried to get actually what is focused on my segment.
Optional(<UISegment: 0x7fe278107a10; frame = (0 0; 189 70); opaque = NO; focused = YES; layer = <CALayer: 0x6100002218e0>>)
So I managed to find out that actually item of UISegmentedControl is focused! How I retrieve this item, since UISegment element is not available as subclass.
Got work around, I set tag for UISegmentedControl.
if let currentFocus = UIScreen.main.focusedView {
if let superView = currentFocus.superview {
if superView.tag == 11 {
}
}
}
And here is how I see if I am on right segmentcontrol.