iOS第五章控件和动作(4)
UIView *mainView = [[[[mySwitch subviews]objectAtIndex:0] subviews] objectAtIndex:2];
UILabel *onLabel = [[mainView subviews]objectAtIndex:0];
UILabel *offLabel = [[mainView subviews]objectAtIndex:1];
修改字体和颜色
onLabel.text = @"YES";
offLabel.text = @"NO";
onLabel.textColor = [UIColor yellowColor];
offLabel.textColor = [UIColor greenColor];
7、控制控件-滑块 UISlider
创建
CGRect sliderRect = CGRectMake(20,50,280,40);
UISlider *mySlider = [[UISlider alloc]initWithFrame: sliderRect];
mySlider.minimumValue = 0;
mySlider.maximumValue = 100;
mySlider.continuous = YES;
……
处理滑动事件
-(void)sliderAction:(id)sender
{
intstepAmount = 10;
floatstepValue = (abs([(UISlider *)sender value]) / stepAmount) * stepAmount;
[sendersetValue: stepValue];
lblSliderValue.text= [NSString stringWithFormat: @"%d", (int)stepValue];
}
相关新闻>>
- 发表评论
-
- 最新评论 更多>>