1、addSubview(view: UIView)//普通添加
2、sendSubviewToBack(view: UIView)//添加到最下层
3、bringSubviewToFront(view: UIView)//添加到最下层
4、insertSubview(view: UIView,atIndex: Int)//添加到制定层
5、insertSubview(view: UIView,belowSubview: UIView)//添加到某个层级的下面
6、insertSubview(view: UIView,aboveSubview: UIView)//添加到摸个层级的上面
修改层级
1、exchangeSubviewAtIndex(index1: Int, withSubviewAtIndex index2: Int)//交换层级
extension UIView {
func addCorner(conrners: UIRectCorner , radius: CGFloat) {
let maskPath = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: conrners, cornerRadii: CGSize(width: radius, height: radius))
let maskLayer = CAShapeLayer()
maskLayer.frame = self.bounds
maskLayer.path = maskPath.cgPath
self.layer.mask = maskLayer
}}