ORKTextScaleAnswerFormat Class Reference

Inherits from ORKAnswerFormat : NSObject
Declared in ORKAnswerFormat.h

The ORKTextScaleAnswerFormat represents an answer format that includes a discrete slider control with a text label next to each step.

The scale answer format produces an ORKChoiceQuestionResult object that contains the selected text choice’s value.

– initWithTextChoices:defaultIndex:vertical:

Returns an initialized text scale answer format using the specified values.

- (instancetype)initWithTextChoices:(NSArray<ORKTextChoice*> *)textChoices defaultIndex:(NSInteger)defaultIndex vertical:(BOOL)vertical

Parameters

textChoices

An array of text choices which will be used to determine the number of steps in the slider, and to fill the text label next to each of the steps. The array must contain between 2 and 8 text choices.

defaultIndex

The default index of the scale. If this value is out of range, the slider is displayed without a default value.

vertical

Pass YES to use a vertical scale; for the default horizontal scale, pass NO.

Return Value

An initialized text scale answer format.

Discussion

This method is the designated initializer.

Declared In

ORKAnswerFormat.h

– initWithTextChoices:defaultIndex:

Returns an initialized text scale answer format using the specified values.

- (instancetype)initWithTextChoices:(NSArray<ORKTextChoice*> *)textChoices defaultIndex:(NSInteger)defaultIndex

Parameters

textChoices

An array of text choices which will be used to determine the number of steps in the slider, and to fill the text label next to each of the steps. The array must contain between 2 and 8 text choices.

defaultIndex

The default index of the scale. If this value is out of range, the slider is displayed without a default value.

Return Value

An initialized text scale answer format.

Discussion

This method is a convenience initializer.

Declared In

ORKAnswerFormat.h

  textChoices

An array of text choices which provides the text to be shown next to each of the slider steps. (read-only)

@property (copy, readonly) NSArray<ORKTextChoice*> *textChoices

Declared In

ORKAnswerFormat.h

  defaultIndex

The default index for the slider. (read-only)

@property (readonly) NSInteger defaultIndex

Discussion

If the value of this property is less than zero or greater than the number of text choices, the slider has no default value.

Declared In

ORKAnswerFormat.h

  vertical

A Boolean value indicating whether the scale is oriented vertically. (read-only)

@property (readonly, getter=isVertical) BOOL vertical

Declared In

ORKAnswerFormat.h

  gradientColors

The colors to use when drawing a color gradient above the slider. Colors are drawn such that lower indexes correspond to the minimum side of the scale, while colors at higher indexes in the array corresond to the maximum side of the scale.

@property (copy, nullable) NSArray<UIColor*> *gradientColors

Discussion

Setting this value to nil results in no gradient being drawn. Defaults to nil.

An example usage would set an array of red and green to visually indicate a scale from bad to good.

Declared In

ORKAnswerFormat.h

  gradientLocations

Indicates the position of gradient stops for the colors specified in gradientColors. Gradient stops are specified as values between 0 and 1. The values must be monotonically increasing.

@property (copy, nullable) NSArray<NSNumber*> *gradientLocations

Discussion

If nil, the stops are spread uniformly across the range. Defaults to nil.

Declared In

ORKAnswerFormat.h