我创建了一个按钮设置背景图像。然后为按钮添加标签,我尝试修改标签中字体的大小但失败了。我不知道如何解决这个问题,请任何人帮助我。
这是我的代码:
returnButton = [UIButton buttonWithType:UIButtonTypeCustom];
returnButton.frame = CGRectMake(10, 9, 50, 28);
[returnButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
[returnButton setImage:[UIImage imageNamed:@"US MEAT_buttons.png"] forState:UIControlStateNormal];
[returnButton setImage:[UIImage imageNamed:@""] forState:UIControlStateHighlighted];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(8, 2, 50, 20)];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.font = [UIFont fontWithName:@"STHeiti-Medium.ttc" size:10];
label.text = @"返回";//返回means "return"
[returnButton addSubview:label];
[label release];