我已经找遍了堆栈溢出,为了这个问题的答案,我只能找到在4.1和更低版本上有效的方法,但是对于4.2.1和更高版本,我找不到一种新的方法来改变打开和关闭的文本。有没有办法把它改成是和不是。这是我目前所拥有的:
UISwitch *switchControl = [[UISwitch alloc] initWithFrame:frame];
[switchControl addTarget:self action:action forControlEvents:UIControlEventValueChanged];
switchControl.backgroundColor = [UIColor clearColor];
switchControl.on = value;
[cell addSubview:switchControl];
[switchControl release];更改UISwitch文本的最简单方法是什么?或者,如果我制作两个图像,并使用动画使它们流动起来,就像是一个普通的UISwitch,会不会更容易。
发布于 2011-02-05 00:30:58
我编写了一个自定义switch类。希望这能有所帮助。http://cl.ly/4OQN
编辑:另外,也可以试试这个:
switchView = [[UICustomSwitch alloc] initWithFrame:CGRectZero];
[switchView setCenter:CGPointMake(160.0f,260.0f)];
[switchView setLeftLabelText: @"Foo"];
[switchView setRightLabelText: @"Bar"];
[[switchView rightLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]];
[[switchView leftLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]];
[[switchView leftLabel] setTextColor:[UIColor yellowColor]];https://stackoverflow.com/questions/4900173
复制相似问题