gpt4 book ai didi

ios - 如何使 UIButton 的一些文字变粗

转载 作者:行者123 更新时间:2023-11-28 18:02:53 26 4
gpt4 key购买 nike

我想将我的 UIButton 标题设置为 === 没有帐户? 注册

如何使一些文本加粗。

    UIButton *signUpButton = [[UIButton alloc]initWithFrame:CGRectMake(40, 270, 240, 40)];
[signUpButton setTitle:@"Don`t have an account? Sign Up" forState:UIControlStateNormal];
[signUpButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
signUpButton.titleLabel.font = [UIFont systemFontOfSize:14];
[signUpButton setBackgroundColor:[UIColor clearColor]];
[signUpButton addTarget:self action:@selector(signUpAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:signUpButton];

无法实现属性字符串..

最佳答案

在这里设置你的按钮文本...

[yourbutton setAttributedTitle:[self UnderLineTextString:strString]
forState:UIControlStateNormal];

请试试这个功能...

-(NSMutableAttributedString *)UnderLineTextString:(NSString *)str
{
NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc] initWithString:str];

[titleString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:20.0] range:NSMakeRange(0, [titleString length])];// set your text lenght..

return titleString;
}

关于ios - 如何使 UIButton 的一些文字变粗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33316976/

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