标签:
字体随滑杆的滑动而变大或变小。用滑杆去控制字体的大小很简单,但用字体去控制自定义tableViewcell内字体的大小也很简单,只不过第一次做的时候可能要摸索一下,这里我就简单的给大家演示一下:
这是一个按钮,点击按钮弹出一个带有slider的view
- (IBAction)btnClick:(id)sender { UIView *sliderView = [[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width-188, 70, 150, 120)]; sliderView.backgroundColor = [UIColor blackColor]; [self.view addSubview:sliderView]; _setField1 = [[UITextField alloc]initWithFrame:CGRectMake(60, 72, 60, 30)]; _setField1.backgroundColor = [UIColor clearColor]; _setField1.textColor = [UIColor whiteColor]; _setField1.font = [UIFont systemFontOfSize:12]; [sliderView addSubview:_setField1]; UISlider *fontSlider = [[UISlider alloc]initWithFrame:CGRectMake(5,77 , 140, 60)]; fontSlider.minimumValue = 10; fontSlider.maximumValue = 20; fontSlider.value = 10; _showFontValue = fontSlider.value; _setField1.text = [NSString stringWithFormat:@"%ld",(long)_showFontValue]; [fontSlider addTarget:self action:@selector(ChangeFont:) forControlEvents:UIControlEventValueChanged]; [sliderView addSubview:fontSlider]; }
这是滑动滑杆所触发的方法:
-(void)ChangeFont:(UISlider *)slider { _font = slider.value; [_tableview reloadData]; NSLog(@"============%@",cell.cell1titlelable.font); }
这是自定义cell中要添加的代码:
cell.cell1titlelable.font = [UIFont systemFontOfSize:_font]; cell.cell1soucelable.font = [UIFont systemFontOfSize:_font]; cell.cell1incollable.font = [UIFont systemFontOfSize:_font];
用UISlider控制自定义tableViewCell中字体的大小
标签:
原文地址:http://www.cnblogs.com/pengoeng/p/4792472.html