我试图通过使用一个层来只显示UIStepper控件的一部分,使用下面的代码
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];但它并没有完全起作用。UIStepper现在只显示UIStepper的左侧(减号边),这是我想要的,但当我按减号边的右侧时,它仍然会增加一个值,而当我按下左侧时,它会减去(我也想要减去左侧的值)。我做错了什么?
谢谢
发布于 2012-05-16 03:21:11
您已将makstoBounds设置为YES。基本上,您可以使用以下命令隐藏UIStepper:
testStepper.layer.bounds= CGRectMake(0, 0, 47, 27);
testStepper.layer.masksToBounds=YES;如果您执行以下操作,您将看到整个UIStepper。
testStepper.layer.bounds= CGRectMake(0, 0, 47, 27);
//testStepper.layer.masksToBounds=YES;https://stackoverflow.com/questions/10598964
复制相似问题