//UILabel的使用方法
let label:UILabel = UILabel(frame: CGRect(x: 0, y: 100, width: view.frame.size.width, height: 100))
label.text = "人人都爱萌叔老,天天不吃药"
label.textAlignment = NSTextAlignment.Center
// label.numberOfLines = 2
//设置文字过长的显示模式
label.lineBreakMode = NSLineBreakMode.ByTruncatingMiddle
//根据文本框范文自动缩放字体,以达到完全显示的目的
label.adjustsFontSizeToFitWidth = true
//字体大小 粗体
// label.font = UIFont.boldSystemFontOfSize(14)
//正常
label.font = UIFont.systemFontOfSize(14)
label.textColor = UIColor.blueColor()
//设置阴影
label.shadowColor = UIColor.cyanColor()
label.shadowOffset = CGSizeMake(1.0, 1.0)
//将文本标签加入视图中
view.addSubview(label)
// 给label添加点击事件
label.userInteractionEnabled = true
let tap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "tap:")
label.addGestureRecognizer(tap)
}
func tap(tap : UITapGestureRecognizer){
print("tihis is click")
}