Resize UIStepper?

Can I resize UIStepper? When I try to set the step size, it seems to be ignored.

UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(50,50,100,100)];
[self.view addSubview:stepper];
NSLog(@"%@",stepper);
CGRect r = CGRectMake(50,50,100,100);
stepper.frame = r;
NSLog(@"%@",stepper);

The magazine says that the frame (50 50; 94 27)

Can I resize from 94, 27?

+5
source share
4 answers

I agree with bani uppal. the step size cannot be changed, you cannot implement the same functionality with two custom buttons and you can set the background images of your buttons to create the impression of a step.

-1
source

You can correctly update the UIStepper size without conversion.

Use the following method to set the background image, and the pedometer will draw itself using the background size:

- (void)setBackgroundImage:(UIImage*)image forState:(UIControlState)state

Example

    [self.stepper1 setIncrementImage:[UIImage imageNamed:@"plusIcon1.png"] forState:UIControlStateNormal];
    [self.stepper1 setDecrementImage:[UIImage imageNamed:@"minusIcon1.png"] forState:UIControlStateNormal];

    [self.stepper1 setBackgroundImage:[UIImage imageNamed:@"stepperBkg1.png"] forState:UIControlStateNormal];
    [self.stepper1 setBackgroundImage:[UIImage imageNamed:@"stepperBkgHighlighted1.png"] forState:UIControlStateHighlighted];
    [self.stepper1 setBackgroundImage:[UIImage imageNamed:@"stepperBkgDisabled1.png"] forState:UIControlStateDisabled];

, : enter image description here

stepperBkg1@2x.png:

enter image description here

stepperBkgHighlighted1@2x.png:

enter image description here

+12

// viewDidLoad

 Stepper.transform = Stepper.transform.scaledBy(x: 10, y: 10)

but it will distract the function to try yourself!

0
source

You cannot resize UIStepper. UIStepper is a subclass of UIView, maybe you can resize using some hack, maybe create a subclass of UIStepper and override drawRect :, I'm not sure if this will work. But at the same time, your application will be at risk of rejection. If you need a different size, the best option is to create a custom component.

-3
source

All Articles