Corey Floyd
6 min readApr 11, 2016

--

Imagine a world in which every single human being can freely share in the sum of all knowledge. That’s our commitment.

Design mockup for a text size slider
public override func drawRect(rect: CGRect) {
super.drawRect(rect)

let ctx = UIGraphicsGetCurrentContext()

CGContextSaveGState(ctx)
// Draw ticks
CGContextSetFillColorWithColor(ctx, self.tickColor.CGColor)

for index in 0..<self.numberOfSteps {
let x = self.trackOffset + CGFloat(index) * self.stepWidth — 0.5 * self.tickWidth
let y = self.bounds.midY — 0.5 * self.tickHeight

// Clip the tick
let tickPath = UIBezierPath(rect: CGRect(x: x , y: y, width: self.tickWidth, height: self.tickHeight))

// Fill the tick
CGContextAddPath(ctx, tickPath.CGPath)
CGContextFillPath(ctx)
}
CGContextRestoreGState(ctx)
}
private func commonInit() {
self.trackLayer.backgroundColor = self.trackColor.CGColor
self.layer.addSublayer(trackLayer)

self.thumbLayer.backgroundColor = UIColor.clearColor().CGColor
self.thumbLayer.fillColor = self.thumbFillColor.CGColor
self.thumbLayer.strokeColor = self.thumbStrokeColor.CGColor
self.thumbLayer.lineWidth = 0.5
self.thumbLayer.frame = CGRect(x: 0, y: 0, width: self.thumbDimension, height: self.thumbDimension)
self.thumbLayer.path = UIBezierPath(ovalInRect: self.thumbLayer.bounds).CGPath

// Shadow
self.thumbLayer.shadowOffset = CGSize(width: 0, height: 2)
self.thumbLayer.shadowColor = UIColor.blackColor().CGColor
self.thumbLayer.shadowOpacity = 0.3
self.thumbLayer.shadowRadius = 2
self.thumbLayer.contentsScale = UIScreen.mainScreen().scale

self.layer.addSublayer(self.thumbLayer)
}
element.accessibilityFrame = [self convertRect:textFrame toView:nil];
@property(nonatomic, assign) UIAccessibilityTraits accessibilityTraits

Use this trait to characterize an accessibility element that users can adjust in a continuous manner, such as a slider or a picker view. If you specify this trait on an accessibility element, you must also implement the accessibilityIncrement and accessibilityDecrement methods in the UIAccessibilityAction protocol.

Navigating the slider using only VoiceOver

--

--

Corey Floyd

Developer, Scotch Drinker, Ambiturner.