开发者

iPad programming, any way to invert color programmatically?

开发者 https://www.devze.com 2023-02-18 15:32 出处:网络
You know how the iPad can invert colors? For the app I\'m working on we wanted to have a button that would invert the colors for one of the views the same way.Does the sdk have any kind of support for

You know how the iPad can invert colors? For the app I'm working on we wanted to have a button that would invert the colors for one of the views the same way. Does the sdk have any kind of support for someth开发者_如何学编程ing like that already?


I don't think that there is an easy way at the moment. CALayer has a compositingFilter property which is described as

A CoreImage filter used to composite the receiver’s contents with the background. Animatable.

It's available since iOS 2.0 but it also says:

While the CALayer class exposes this property, Core Image is not available in iOS. Currently the filters available for this property are undefined.

Core Image would have been ideal for that purpose, it does provide a filter (CIColorInvert) to invert colors.

Another apporach would be: Change the color properties of the UI controls you are using, though I doubt that everything will look they way you expect, as there may be gradients and such. You have to implement your own small algorithm to invert a given color.

I see only the hard way: You have to draw your controls manually with drawRect and invert the colors with your own algorithm there.

0

精彩评论

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