UIStepper only show minus sign

478 Views Asked by At

I'm trying to only show one part of h the UIStepper control by using a layer, using this code

UIStepper *testStepper = [[UIStepper alloc]init];
[testStepper setFrame:CGRectMake(120, 220, 94, 27)];
testStepper.maximumValue = 5;
testStepper.minimumValue = 1;
testStepper.value = 1;

testStepper.layer.cornerRadius =3;
testStepper.layer.bounds= CGRectMake(0, 0, 47, 27);
testStepper.layer.masksToBounds=YES;
testStepper.layer.opacity = 1;

[self.view addSubview:testStepper];

but it isn't completely working. The UIStepper now only shows the left side of the UIStepper (the minus side) which is what I want, but when i press the right side of the minus side, it still adds a value, and when I press the left side it subtracts (what I want for the left side too). What am I doing wrong?

Thanks

1

There are 1 best solutions below

2
On

You have makstoBounds set to YES. Basically you are hiding the UIStepper with:

testStepper.layer.bounds= CGRectMake(0, 0, 47, 27);
testStepper.layer.masksToBounds=YES;

if you do the following you will see the whole UIStepper.

testStepper.layer.bounds= CGRectMake(0, 0, 47, 27);
//testStepper.layer.masksToBounds=YES;