ios 動態修改UILabel字體大小

- (IBAction)sliderChange:(id)sender

{

  NSLog(@"sliderChange");

  UISlider *slider = (UISlider *) sender;

  NSString *labelContent = dynamic_label.text;

   /**********中間部分比較重要*********************/

  CGSize size = [labelContent sizeWithFont:dynamic_label.font constrainedToSize:CGSizeMake(320, 480) lineBreakMode:UILineBreakModeWordWrap];

  CGRect rect = dynamic_label.frame;

  rect.size = size;

  dynamic_label.frame = rect;

  dynamic_label.font = [UIFont fontWithName:dynamic_label.font.fontName size:defautlTextSize * (1 + slider.value)];

   /**********中間部分比較重要*********************/

  NSLog(@"value is %.2f", slider.value);

}
相關文章
相關標籤/搜索