添加图片
let img = UIImage(named: "test")
let imgView = UIImageView(image: img)
imgView.frame = CGRect(x:24,y:80,width:272,height:410)
self.view.addSubview(imgView)
为图片添加边框
//为图片添加边框
//设置边框宽度
imgView.layer.borderWidth = 10
//设置边框颜色
imgView.layer.borderColor = UIColor.lightGray.cgColor
为图片添加圆角
//设置圆角半径
imgView.layer.cornerRadius = 8
//设置遮罩,裁剪边界
imgView.layer.masksToBounds = true
为图片添加阴影
//设置阴影的颜色
imgView.layer.shadowColor = UIColor.black.cgColor
//设置阴影的偏移量
imgView.layer.shadowOffset = CGSize(width: 10.0, height: 10.0)
//设置阴影透明度
imgView.layer.shadowOpacity = 0.45
//设置阴影半径
imgView.layer.shadowRadius = 5.0