我想添加邊框到孔中的切口(在中間和半透明外側清晰)。我爲此使用了PartialTransparentMaskView。切割圓形邊框Swift
https://github.com/heigong/PartialTransparentMaskView
的代碼看起來像這樣
mapView.clipsToBounds = false
let frame = mapView.frame
// Add the mask view
var array = [CGRect]()
//to change the circle customize next line
let rect = CGRectMake(frame.origin.x+20,100, frame.width-40, frame.height-300)
array.append(rect)
let maskColor = UIColor(red: 0.9, green: 0.5, blue: 0.9, alpha: 0.5)
let parentView = mapView.superview
let pFrame = parentView!.frame
let maskView = PartialTransparentMaskView(frame: CGRectMake(0, 0, pFrame.width, pFrame.height), backgroundColor: maskColor, transparentRects: nil, transparentCircles:array, targetView: mapView)
parentView!.insertSubview(maskView, aboveSubview: mapView)
我如何添加一個紅框繞了一圈?
我不明白,什麼是錯的這件事嗎?如果你打算把我的答案投下來,請至少讓我知道爲什麼我錯了。 –
它是顯示邊框的Maskview,這是整個框架。我想要它的內部圓形區域。 – subodh1989
我已經更新了我的答案,我最初認爲面具視圖是圓圈。我很抱歉,這並不明顯。這對你有幫助嗎? –