【发布时间】:2015-10-27 17:01:43
【问题描述】:
嘿,我想更改标签的字体而不更改大小,因为我对不同的设备有不同的大小 请参阅下面的代码:-
此代码有效,但正如我所说,我不想更改大小
QuotesLabel.font = UIFont(name: "optima", size: CGFloat(30)
这里是不同设备不同尺寸的代码
if UIScreen.mainScreen().bounds.size.height == 480 {
// iPhone 4
QuotesLabel.font = QuotesLabel.font.fontWithSize(30)
} else if UIScreen.mainScreen().bounds.size.height == 568 {
// IPhone 5
QuotesLabel.font = QuotesLabel.font.fontWithSize(30)
} else if UIScreen.mainScreen().bounds.size.width == 375 {
// iPhone 6
QuotesLabel.font = QuotesLabel.font.fontWithSize(35)
} else if UIScreen.mainScreen().bounds.size.width == 414 {
// iPhone 6+
QuotesLabel.font = QuotesLabel.font.fontWithSize(40)
}
【问题讨论】:
-
如果 QuotesLabel 不是一个类,它应该以小写的 'quotesLabel' 开头。