简体   繁体   English

UIControl子类裁剪中的自定义工程图

[英]Custom Drawing in UIControl Subclass Clipping

So, I'm doing some custom drawing in a UIControl subclass by overriding the drawRect: method. 因此,我通过重写drawRect:方法在UIControl子类中进行一些自定义绘制。 The issue is that the control is clipping a glow that I drew in it even though I've set the clipsToBounds property to NO . 问题是,即使将clipsToBounds属性设置为NO ,该控件也会裁剪我在其中绘制的光晕。

Any ideas? 有任何想法吗?

EmeilioPelaez has it right. EmeilioPelaez正确。 You can't draw outside your own frame. 您不能在自己的框架之外绘制。 If you want the glow to overlap other UI elements, make the frame big enough to draw the glow, then make sure to set your own opaque flag to NO, and set the backgroundColor to [UIColor clearColor] . 如果要让光晕与其他UI元素重叠,请使框架足够大以绘制光晕,然后确保将自己的opaque标志设置为NO,并将backgroundColor设置为[UIColor clearColor] Keep in mind, compositing views incurs a pretty big performance hit, so maybe ask yourself if drawing that glow on top of other elements is really necessary. 请记住,合成视图会带来很大的性能损失,因此也许要问自己,是否真的有必要在其他元素之上绘制发光效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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