Transparent repaint on UIView
I'm making an iPhone-app with particles moving on a custom UIView, drawn with Core Graphics. I want my particles to leave a trace, so when the view is repainted I want it to fill the background with 0.8 alpha.
Anyone knows how to do this? I've tried setting the background color of the view to something transparent in IB, but that doesn't help, it only makes the underlyin开发者_开发百科g view visible through.
In short - I need help setting the clear color of UIView to something transparent.
Thanks
If you want your view transparent check the opaque property. If it's opaque - no transparency will happen (http://developer.apple.com/iphone/library/documentation/uikit/reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/opaque)
And you can set a clear color as the background too ([UIColor clearColor]).
you can't have your view paint over what's already in it. Whenever drawRect is called, you have to draw the entire contents of the view from scratch.
You could instead use a CGBitmapContext to draw into, which you can keep around as long as you want. Then in your view, just draw the CGBitmapContext in its entirety into the view.
http://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/CGBitmapContext/Reference/reference.html
精彩评论