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];
}
相关新闻>>
- 发表评论
-
- 最新评论 进入详细评论页>>
今日头条
更多>>您可能感兴趣的文章
- 深入理解iPhone静态库(手把手教你iphone开发
- Cocoa Core Competencies 的Object creation 和IOS面试题示例
- iOS文件存磁盘的设想
- ios 时间定时器 NSTimer应用demo
- iPhone开发 文件的增加删除查询
- iphone开发基础三和c语言混编
- iphone-使用TextField及关闭键盘(useing TextField for in
- iPhone开发 调用阿asp.net程序的webservice
- (iOS-iap防护)验证用户付费收据,拒绝iap
- ios 关于UITableView UITableViewCellAccessoryCheckmark 混乱的