How To Create Mask one UIView using Another UIView ?
UIView have mask property that allow cuts particular parts depending you need. This mask applied any other kind of UIView. Here the example of mask cuts circle.
Define the Main View:
let redV = UIView(frame: CGRect(x: 50, y: 50, width: 128, height: 128))
redV.backgroundColor = .red
view.addSubview(redV
)
Add Mask:
let maskView = UIView(frame: CGRect(x: 0, y: 64, width: 128, height: 128))
maskView.backgroundColor = .red
maskView.layer.cornerRadius = 64
redV.mask = maskView
Add Mask:
let maskView = UIView(frame: CGRect(x: 64, y: 64, width: 128, height: 128))
maskView.backgroundColor = .red
maskView.layer.cornerRadius = 64
redV.mask = maskView
Thanks.
How To Create Mask one UIView using Another UIView ?
Reviewed by KIRIT MODI
on
21:56:00
Rating:
No comments: