Is it possible to change the size of a UIStepper? When i try to set the size of a stepper it seems to get 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);
Log says the frame is (50 50; 94 27)
Is it possible to change the size from 94, 27?
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