English 中文(简体)
IDWebView或UITextView中的校外彩
原标题:Invert colors in UIWebView or UITextView

我很想知道,是否有任何人知道有轻松的办法来抹去“IDWeb”的颜色。 View或UITextView。 我知道有可能在“你”一栏上 all倒一切,但我并不希望用户必须做事,他们应当能够用一个点击来照亮颜色,这样,如果情况不好,阅读一些东西就会更容易,而且对用户周围的人的影响也会更少。

感谢任何帮助!

最佳回答

这里,我通过注射 j语在“IDWebView”(过去)。

第一编

#define invertJS @"function load_script(src,callback){var s=document.createElement( script );s.src=src;s.onload=callback;document.getElementsByTagName( head )[0].appendChild(s);}function invertColors(){var colorProperties=[ color , background-color ];$( * ).each(function(){var color=null;for(var prop in colorProperties){prop=colorProperties[prop];if(!$(this).css(prop))continue;color=new RGBColor($(this).css(prop));if(color.ok){$(this).css(prop, rgb( +(255-color.r)+ , +(255-color.g)+ , +(255-color.b)+ ) );}color=null;}});}load_script( http://www.phpied.com/files/rgbcolor/rgbcolor.js ,function(){if(!window.jQuery)load_script( https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js ,invertColors);else invertColors();})"

And then when your webview finishes loading

- (void)webViewDidFinishLoad:(UIWebView *)webview{
[webview stringByEvaluatingJavaScriptFromString:invertJS];}
问题回答

关于UITextView,你可以确定文字的肤色和背景的肤色属性,我从那里知道,你可以建立一个子,在白色背/黑体字和黑背/白色案文之间转用。 不幸的是,我看不到《国歌》的任何类似属性。

UITextViewsrel=“t”查询。

同样,在将颜色传入这些特性时,你可以使用海克斯的数值,而不是 Apple果的先兆。 这样,你就可以把属性的价值称作天花,用任何几种公式加以改变,并将新的海牛价值回馈给特性。

Inverting a Hex color, put simply:

// maximum hex value is FFFFFF, so
newHex = FFFFFF - oldHex;

I ended up just making two separate files on my server. One that is inverted and one that is regular. There does not seem to be anything in core graphics at least that I could find that would easily do this and to be honest HTML or CSS are definitely not my strong points. Still if anyone has a simpler solution for this I am more than interested in a good idea.





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签