let btn = UIButton(type: .System)
btn.frame = CGRect(x: 100, y: 100, width: 100, height: 100)
btn.backgroundColor = UIColor.redColor()
self.view.addSubview(btn)
//CoreAnimation
//UIView拥有一个CALayer,控制显示功能
//圆角半径
btn.layer.cornerRadius = 50
//边框颜色
btn.layer.borderColor = UIColor.yellowColor().CGColor
//边框宽度
btn.layer.borderWidth = 2
//设置阴影颜色
btn.layer.shadowColor = UIColor.blackColor().CGColor
//阴影的透明度默认是0, 看不见
btn.layer.shadowOpacity = 1
//width: 相对于原图形向右平移, 否者相反
//height: 相对于原图形向下平移, 否者相反
btn.layer.shadowOffset = CGSize(width: 10, height: 20)
//阴影半径
btn.layer.shadowRadius = 20
网友评论