【发布时间】:2013-01-03 00:12:48
【问题描述】:
在我的 iPhone 应用程序中。我想在单击按钮时更改标签中的文本大小
【问题讨论】:
标签: iphone ios objective-c ios5 uibutton
在我的 iPhone 应用程序中。我想在单击按钮时更改标签中的文本大小
【问题讨论】:
标签: iphone ios objective-c ios5 uibutton
创建UILabel
self.lbl=[[UILabel alloc] initWithFrame:CGRectMake(135, 290,200,35)];
self.lbl.backgroundColor=[UIColor clearColor];
NSString *str=[NSString stringWithFormat:@"%.f",[self.slider value]];
[self.lbl setFont:[UIFont fontWithName:@"Arial-BoldMT" size:16]];
self.lbl.text=str;
[self.View addSubview:self.lbl];
点击UIButton时更改UILabel的文本大小
-(IBAction)ButtonPressed:(id)sender
{
[self.lbl setFont:[UIFont fontWithName:@"Arial-BoldMT" size:25]];
}
【讨论】:
-(IBAction)changeFontOfLabel:(id)sender
{
[self.lebelObject setFont:[UIFont fontWithName:@"American Typewriter" size:18];
}
并写下正确的字体名称。在这里查看fonts的列表
【讨论】:
这里是如何在运行时更改字体大小....
yourLabel.font=[UIFont systemFontOfSize:14];
【讨论】: