Change appearance of UIStepper

5 Solutions Collect From Internet About “Change appearance of UIStepper”

You cannot presently do this. You’ll have to write a custom UIControl object if you want to customize the icons.

From the UIStepper Class Reference, the only parameters you can change are

  continuous  property
  autorepeat  property
  wraps  property
  minimumValue  property
  maximumValue  property
  stepValue  property

  value  property

You cannot customize the icons.

However, since it is a subclass of UIView, you can try changing the backgroundColor.

As of iOS 6.0 you can use - (UIImage *)decrementImageForState:(UIControlState)state and - (UIImage *)incrementImageForState:(UIControlState)state to change the labels on the UIStepper control.

This works for iOS 6.0:

[_stepper setDecrementImage:[UIImage imageNamed:@"decrementIcon.png"] forState:UIControlStateNormal];

This works:

[[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundImage:[UIImage imageNamed:@"normal.png"] forState:UIControlStateNormal];
[[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundImage:[UIImage imageNamed:@"highlighted.png"]  forState:UIControlStateHighlighted];
[[UIButton appearanceWhenContainedIn:[UIStepper class], nil] setBackgroundImage:[UIImage imageNamed:@"disabled.png"]  forState:UIControlStateDisabled];

Not sure how future proof it is though.

Here is solution that works for me.

Platform iOS 7.1

[stepper setBackgroundImage:[UIImage new] forState:UIControlStateNormal];
[stepper setDividerImage:[UIImage new] forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal];

The result is only increment, decrement images are visible.

You can always step through the UIViews and guess, too. Anyway, this is my code, which doesn’t answer the question directly, but is kind of neat.

@implementation UIStepper (Util)

- (void) fixForIos7 {
    if (!IS_IOS7)
    for (UIView *view in self.subviews) {
        view.backgroundColor = [UIColor whiteColor];
        UIButton *button = (UIButton*)view;
        [button setTintColor:[UIColor blackColor]];