Skip to content
ChrisSchneider edited this page Jun 15, 2012 · 18 revisions

Inherits from: EKSwipeControl : UIControl : UIView : UIResponder : NSObject

Conforms to:

  • NSCoding (UIView)
  • UIAppearance (UIView)
  • UIAppearanceContainer (UIView)
  • NSObject (NSObject)

Overview


EKSwipeSlider provides a slider similar to UISlider. A trackView is added to the overlayView representing the specified value. When the overlay is displayed, the anchor point is moved on the x-axis to the left or right depending on the value of the slider. The value can be limited using the minimumValue and maximumValue properties.

Example Example
The slider adjusts its position depending on the value when touched. The orange point represents the touch point.

It is recommended to use the swipe slider only as a shortcut and to display a full-featured popover if the user taps the control!
For example the volume can be quickly adjusted using the swipe-slider. For precise control or AirPlay-configuration a popover with a MPVolumeView is displayed.

Vertical sliders are not supported because they are easily hidden by the user's hand.

Appearance

In addition to the functionality provided by EKSwipeControl, this control supports setting the track color for specific events via an appearance proxy. Please note that containment is not supported!

Default appearance of the Track

    [self.appearance setTrackColor:[UIColor colorWithWhite:0.4f alpha:0.5f] forState:EKSwipeControlOverlayVisibleState];
    [self.appearance setTrackColor:[UIColor colorWithWhite:0.4f alpha:0.3f] forState:EKSwipeControlOverlayFadedState];

Default appearance of the Overlay

    [self.appearance setOverlayColor:[UIColor colorWithWhite:0.5f alpha:0.5f] forState:EKSwipeControlOverlayVisibleState];
    [self.appearance setOverlayColor:[UIColor colorWithWhite:0.5f alpha:0.3f] forState:EKSwipeControlOverlayFadedState];

Tasks


Value

@property (nonatomic) float value;
- (void)setValue:(float)value animated:(BOOL)animated;

Used to get & set the value of the slider.

Value Limits

@property (nonatomic) float minimumValue;
@property (nonatomic) float maximumValue;

Specify the minimum and maximum value of the slider.

Subviews

Track View

@property (strong, nonatomic) IBOutlet UIView *trackView;

The view-object that is displayed as the track. Defaults to a UIView.

Behavior

Continuos

@property (nonatomic, getter=isContinuous) BOOL continuous;

Indicates whether changes in the sliders value generate continuous update events.

Layout

Track Rect

- (CGRect)trackRectForBounds:(CGRect)bounds;

The size and position of the track rect.

Overlay Width

@property (nonatomic) CGFloat width;

The width of the overlay.

Overlay Offset

@property (nonatomic) CGFloat offset;

The offset of the overlay.

Appearance

Setting and getting the Track Color for a Specific State

- (UIColor *)trackColorForState:(UIControlState)state UI_APPEARANCE_SELECTOR;
- (void)setTrackColor:(UIColor *)color forState:(UIControlState)state UI_APPEARANCE_SELECTOR;

Assigns a track color for a specific state.

Obtaining the the current track color

@property (readonly, strong, nonatomic) UIColor *currentTrackColor;

This method returns the current color of the track. The color is obtained by performing the trackColorForState: method on the current object. If no color is returned, the appearance proxy of the current class is used.

The method tries to obtain the color using the following states:

  1. current state
  2. EKSwipeControlOverlayFadedState
    if the EKSwipeControlOverlayFadedState flag is set
  3. EKSwipeControlOverlayVisibleState
    if the EKSwipeControlOverlayVisibleState flag is set
  4. UIControlStateNormal
  5. Fallback to: [UIColor colorWithWhite:0.4f alpha:0.5f]