// 店名
let leftNavShop: UILabel = {
let label = UILabel()
label.text = "xxx"
label.textColor = UIColor.white
label.font = UIFont.adjustBoldFontSize(ofSize: 15)
label.shadowColor = UIColor.black.withAlphaComponent(0.3)
label.shadowOffset = CGSize(width: 2, height: 2)
return label
}()
// 阴影的颜色
label.shadowColor = UIColor.black.withAlphaComponent(0.3)
// 阴影的偏移
label.shadowOffset = CGSize(width: 2, height: 2)
width: 正 -> 右,负 -> 左
height:正 -> 下,负 -> 上
#这里的width、height代表的是x、y值。
方法二
// 设置阴影
func setShadow(color:UIColor, offset:CGSize, opacity:Float, radius:CGFloat) {
//设置阴影颜色
self.layer.shadowColor = color.cgColor
//设置阴影偏移量
self.layer.shadowOffset = offset
//设置透明度
self.layer.shadowOpacity = opacity
//设置阴影半径
self.layer.shadowRadius = radius
}
网友评论