I can't seem to change the size of UIStepper
:
I used initWithFrame
:
UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(300, 638, 120, 80)];
But it does not change the size. Several posts on SO seemed to implied it is changeable. Any suggestion?
UIStepper* s = [UIStepper alloc] init];
s.transform = CGAffineTransformMakeScale(0.75, 0.75);
You can properly update the UIStepper size without transformation.
Use the following method to set the background image and the stepper 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];
This yields the following result on the left, compared to an unmodified stepper on the right:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With