如图,上面两个圆角的框线不见了
程式 如下,
let companyTitleView = UIView(frame: CGRect(x: FrameWidth * 0.045, y: naviBar.frame.size.height + FrameWidth * 0.03, width: FrameWidth * 0.91, height: FrameWidth * 0.26))
companyTitleView.backgroundColor = UIColor.white
let radio:CGSize = CGSize(width: 10, height: 10)
let corner:UIRectCorner = [.topLeft,.topRight]
let path = UIBezierPath(roundedRect: companyTitleView.bounds, byRoundingCorners: corner, cornerRadii: radio)
let masklayer:CAShapeLayer = CAShapeLayer()
masklayer.frame = companyTitleView.bounds
masklayer.path = path.cgPath
companyTitleView.layer.mask = masklayer
companyTitleView.layer.borderColor = myFunc.MYFUNC.colorHex("#CCCCCC").cgColor
companyTitleView.layer.borderWidth = 1
self.view.addSubview(companyTitleView)
请问各位大大,怎么让圆角的框线出现?感谢
因为你的边框是原本View上的而且外边框不是圆角矩形,所有用mask裁剪之后自然就不见了。
你需要做的是,
原View自己的边框设置成圆角(但现在能这样做的话你还设啥圆角遮罩呢……),所以或者
原View不要边框,给有圆角遮罩加边框。也就是
这个对象。应该有stroke(边框线)相关的属性或方法。
参考:UIBezierPath