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
? ? }}