开发者

Draw on Screen From A thread

开发者 https://www.devze.com 2023-03-09 15:04 出处:网络
Need to be able to draw on the screen from a thread other than main.Cannot use UIkit since it\'s not thread safe.Would Quartz 2D work in a thread?If so, how do I get to the screen to place the graphic

Need to be able to draw on the screen from a thread other than main. Cannot use UIkit since it's not thread safe. Would Quartz 2D work in a thread? If so, how do I get to the screen to place the graphics? Clea开发者_如何学Gorly I'm a real newbie with graphics and any help would be appreciated.


Yes Quartz would work in thread. However you cannot create a context in other thread. You have to pass the context from main thread. I believe create a CGContextRef in -drawRect method and pass it to thread. Take precaution that context dont go out of scope or just retain its reference.

How to get a screen to put graphics.. well as I said you need some place to create a context, may be some derived class of NSVIew. Then in -drawRect method make a context and pass it to thread.

CGContextRef contextref = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];

Cheers!

0

精彩评论

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