VoiceOver with UISegmentedControl in Swift

By trifusion, 8 September, 2016

Forum
App Development and Programming

I am trying to add VoiceOver to a Segmented Control but the Apple example code does not work with Swift 3:

The Objective C code:
NSString *title = @”∫”;
title.accessibilityLabel = @”Integral”;
[segmentedControl insertedSegmentedWithTitle:title];

does not work with Swift like this:
var title: NSString = "∫"
title.accessibilityLabel = "Integral"
segmentedControl.insertSegment(withTitle: title, at: 0, animated: false)

Swift will only accept a String but I need to add an NSString since it has the VoiceOver attributes.

Can any help with this?

Is there a better approach for adding accessibility or VoiceOver to a segmented control?

Thanks

Greg

Options