我已在代码下方创建,以便更改文本是否被截断的文本。但它似乎根本不起作用。如何检查文本是否被截断,然后更改字符串,如果是?
//Check text sizes
let awaySize: CGSize = (match?.awayName?.uppercaseString.sizeWithAttributes([NSFontAttributeName: UIFont.boldSystemFontOfSize(30)]))!
let homeSize: CGSize = (match?.awayName?.uppercaseString.sizeWithAttributes([NSFontAttributeName: UIFont.boldSystemFontOfSize(30)]))!
if awaySize.width > awayTeam.frame.size.width {
awayTeam.text = match?.awayAcro?.uppercaseString
} else {
awayTeam.text = match?.awayName?.uppercaseString
}
if homeSize.width > homeTeam.frame.size.width {
homeTeam.text = match?.homeAcro?.uppercaseString
} else {
homeTeam.text = match?.homeName?.uppercaseString
}
答案 0 :(得分:1)
我认为可以这样做:
current position