gpt4 book ai didi

ios - 如何修改标签的字体大小

转载 作者:行者123 更新时间:2023-11-29 04:12:28 28 4
gpt4 key购买 nike

我创建一个按钮设置背景图像。然后向按钮添加一个标签,我尝试修改标签中的字体大小但失败。我不知道如何解决这个问题,请有人帮助我。

这是我的代码:

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];

最佳答案

也许您的自定义字体尚未正确添加:

  1. 将字体文件添加到资源文件中
  2. 编辑您的 Info.plist:使用应用程序提供的关键字体添加一个新条目。
  3. 对于每个文件,将文件名添加到此数组

    label.font = [UIFont fontWithName:@"STHeiti-Medium"size:10];

请检查以下答案How to include and use new fonts in iPhone SDK?

关于ios - 如何修改标签的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14209072/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com