A)设置UILabel.Font属性:
myLabel.Font = [UIFont italicSystemFontOfSize: 12.0];
B)或使用属性字符串做类似的事情:
myLabel.attributedText = [[NSAttributedString alloc] initWithString: @"my text" attributes: @{NSFontAttributename: [UIFont italicSystemFontOfSize: 12.0]}]]
但我不想在意大小.我只想要“默认”字体和大小,但用斜体字.目前,我实际上使用的是obliqueness属性:
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString: @"My Text" attributes: @{NSObliquenessAttributename: @(0.5)}];myLabel.attributedText = text;
这使得我不必关心任何大小,但我认为倾斜只是近似斜体.
解决方法 您可以使用[UIFont systemFontSize].myLabel.attributedText = [[NSAttributedString alloc] initWithString: @"my text" attributes: @{ NSFontAttributename: [UIFont italicSystemFontOfSize: [UIFont systemFontSize]]}]];
此外,还有更多选择可供选择:
+ (CGfloat)labelFontSize;//Returns the standard Font size used for labels.+ (CGfloat)buttonFontSize;//Returns the standard Font size used for buttons.+ (CGfloat)smallSystemFontSize;//Returns the size of the standard small system Font.+ (CGfloat)systemFontSize;//Returns the size of the standard system Font.总结
以上是内存溢出为你收集整理的ios – 如何在不关心尺寸的情况下制作斜体UILabel?全部内容,希望文章能够帮你解决ios – 如何在不关心尺寸的情况下制作斜体UILabel?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)