简体   繁体   中英

Setting UIView dimensions with Bezier Path

i'll preface by saying i'm less than a month into programming with swift. so i've still heavy in the learning phase and much of the stuff online i've search has been written in Objective-C.

my problem right now is that, I have been using a CA Layer to display images. (i want to use CA layers because of the animating properties they have that I plan to utilize)

the layer is itself is connect with my UIView like this:

@IBOutlet weak var myView: UIView!

var l: CALayer {
    return myView.layer
}

now i have set the UIView in storyboard something like x:100, y:100, w:100, h:100.

but instead of a 100x100 square to put my image into. I want a polygon shape that I can custom draw with bezier points.

how can i draw the bezier path and set the frame/bound? of the UIView to this custom bezier shape?

this is my first post. i hope that i phrased this question right and didn't overlook any obvious solutions.

After creating your UIBezierPath , have you tried doing path.addClip() ? That will serve the purpose I think.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM