使用したのは追記していきます。
Swift3
基本
let label: UILabel = UILabel()
label.backgroundColor = UIColor.orange
label.text = "テキスト"
label.font = UIFont(name: "HiraKakuProN-W6", size: 8.5)
label1.textColor = UIColor.white
self.addSubview(label1)
その他
//文字寄せ
label.textAlignment = NSTextAlignment.right
label.textAlignment = NSTextAlignment.center
//角を丸くする
self.imageView.layer.masksToBounds = true //マスク設定
label.layer.cornerRadius = 1.0
//背景を画像に
label.backgroundColor = UIColor(patternImage: UIImage(named: "hogeImg")!)
objc
//背景を画像に
label.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"blah"]];
UILabelを使って何か調べる
//UILabelの行数を調べる
NSInteger lineCount = 0;
CGSize textSize = CGSizeMake(cell.replyBody.frame.size.width, MAXFLOAT);
long rHeight = lroundf([cell.replyBody sizeThatFits:textSize].height);
long charSize = lroundf(cell.replyBody.font.leading); //ここはフォントによって微妙に変更する必要がある場合あり
lineCount = rHeight/charSize;