开发者

How do I use CGContext to draw on top of an existing UIView?

开发者 https://www.devze.com 2023-01-07 18:51 出处:网络
I have a subclass of UIView in which I\'ve added some subviews to in my initWithFrame method. I\'ve added a background, amongst other things.

I have a subclass of UIView in which I've added some subviews to in my initWithFrame method. I've added a background, amongst other things.

I want to draw some shapes on top of these views (which happen to cover the entire scre开发者_运维问答en). But, when I implement drawRect: to draw these shapes, they didn't show up. Upon removing the other subviews, I realized that the shapes were begin drawn "under" the other subviews.

How can I draw them on top?


Call [super drawRect:rect] at the beginning of the drawRect: for the owning view. This will draw all the subviews into the current context. Additional drawing you do for the owning view should then go on top.


Maybe, you should add transparent view on top of others and draw shapes on it?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号