0

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

Kridie
  • 1
  • 1

1 Answers1

1

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;
Joe
  • 2,987
  • 15
  • 24
  • Well, I think this is what happens: When I set the bounds to (0,0,47,27) the UIStepper only shows the minus sign. But it also scales the Buttons within the UIStepper so the created UIStepper with only the minus sign, still has two halves where the left part handles the subtraction and the right side addition. Is it possible to remove this behavior? – Kridie May 18 '12 at 17:39
  • Why are you using the bounds? – Joe May 18 '12 at 18:18