简体   繁体   中英

How to get the graphics context of an UIView?

For example, I want to draw something directly to an UIView. I need an CGContextRef, but I don't want to make a new one since that would eat up too much memory. Can I obtain the CGContextRef from an UIView?

仅在 drawRect 方法中:

UIGraphicsGetCurrentContext()

Outside of the redraw call, I do not believe so. I remember trying this myself a while ago. Sorry I can't be more specific, but I've not touched the iPhone SDK in months.

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