MMMHorizontalPicker

Objective-C

@interface MMMHorizontalPicker : UIView

Swift

class MMMHorizontalPicker : UIView

Allows to swipe horizontally through a lot of items ensuring only a handful of subviews are used. The views corresponding to each element can be of different width and can use Auto Layout.

NOTE: When widths of items are very different, then scrolling and panning can be a bit funky.

  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, readonly) MMMHorizontalPickerStyle style

    Swift

    var style: MMMHorizontalPickerStyle { get }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) id<MMMHorizontalPickerDelegate> delegate

    Swift

    weak var delegate: MMMHorizontalPickerDelegate? { get set }
  • All the item views will be positioned within the rect obtained by insetting the bounds by these insets.

    Declaration

    Objective-C

    @property (nonatomic) UIEdgeInsets contentInsets;

    Swift

    var contentInsets: UIEdgeInsets { get set }
  • The distance to keep between two neigbour item views.

    Note

    Note that this does not work as expected when dragging item views that are different in size.

    Declaration

    Objective-C

    @property (nonatomic) CGFloat spacing;

    Swift

    var spacing: CGFloat { get set }
  • Optional view which when set is used to calculate prefered height of the picker.

    Declaration

    Objective-C

    @property (nonatomic, nullable) UIView *prototypeView;

    Swift

    var prototypeView: UIView? { get set }
  • The index of the item closest to the center of the picker’s viewport.

    Note

    Note that when set it will be always clipped into [0; numbersOfItems - 1] range.

    Declaration

    Objective-C

    @property (nonatomic) NSInteger currentItemIndex;

    Swift

    var currentItemIndex: Int { get set }
  • Undocumented

    Declaration

    Objective-C

    - (void)setCurrentItemIndex:(NSInteger)currentItemIndex animated:(BOOL)animated;

    Swift

    func setCurrentItemIndex(_ currentItemIndex: Int, animated: Bool)
  • Should be called when the number of items change.

    Declaration

    Objective-C

    - (void)reload;

    Swift

    func reload()
  • Undocumented

    Declaration

    Objective-C

    - (id)initWithStyle:(MMMHorizontalPickerStyle)style NS_DESIGNATED_INITIALIZER;

    Swift

    init(style: MMMHorizontalPickerStyle)
  • Convenience initializer using “default” picker style.

    Declaration

    Objective-C

    - (nonnull id)init;

    Swift

    convenience init()
  • Unavailable

    Undocumented

    Declaration

    Objective-C

    - (id)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
  • Unavailable

    Undocumented

    Declaration

    Objective-C

    - (id)initWithCoder:(NSCoder *)aDecoder NS_UNAVAILABLE;