如何在UIButton上动态设置不同的字体?

问题描述:

我想动态设置按钮标题的自定义字体,所以我怎么设置它。如何在UIButton上动态设置不同的字体?

UIButton *button  = [UIButton buttonWithType: UIButtonTypeRoundedRect]; 
button.titleLabel.font = [UIFont fontWithName:@"font name" size:12]; 

[tmp setFont:[UIFont fontWithName:@"American Typewriter" size:18]]; 

的字体名称把它从一个数组和不断变化的指数。

所以它看起来像

[tmp setFont:[UIFont fontWithName:[fontArray objectAtIndex:desiredIndex] size:18]]; 
+1

setfont程序已经过时,它不是working.Do您有任何替代解决方案请。 – 2011-02-16 09:57:13