func setTitleLabel(text: String) {
let titleLabel = UILabel()
self.view.addSubview(titleLabel)
titleLabel.text = text
titleLabel.lineBreakMode = .ByWordWrapping
titleLabel.numberOfLines = 2
titleLabel.font = UIFont(name: "AvenirNext-Medium", size: 22)
titleLabel.textColor = UIColor(red: 162/255, green: 28/255, blue: 194/255, alpha: 1)
titleLabel.snp_makeConstraints { (make) -> Void in
make.centerX.equalTo(self.view)
make.top.equalTo(self.view.snp_top).offset(20)
}
}
我的标签有这种功能,但实际上标签的标签文字很长。我可以做什么?我写了这个:
titleLabel.lineBreakMode = .ByWordWrapping
titleLabel.numberOfLines = 2
但这对我没有帮助
答案 0 :(得分:0)
尝试约束标签的宽度。如果你不这样做,它将使用其内在的内容大小,标签将变得更宽,以便文本可以适应它。
答案 1 :(得分:0)
答案 2 :(得分:0)
您应该尝试使用numberOfLines
,如下所示
titleLabel.numberOfLines = 0
答案 3 :(得分:0)
尝试这个
WITH AllData AS
(
SELECT use_ID,use_postingUser
,Usr.value('@User','int') AS AttribUser
,Usr.value('@Answ','varchar(max)') AS AttribAnsw
FROM @tbl AS tbl
CROSS APPLY use_UseAnsw.nodes('/UseAnsw/User') AS One(Usr)
)
SELECT DistinctUsers.use_PostingUser
,COUNT(AllData.AttribUser) AS CountAttribUser
FROM @tbl AS DistinctUsers
LEFT JOIN AllData ON DistinctUsers.use_PostingUser=AllData.AttribUser
GROUP BY DistinctUsers.use_PostingUser
并将此代码添加到viewDidLoad()
中@IBOutlet weak var feedNoteLabel: UILabel!