Loupe Magnification with White Text & Clear Background on Iphone - iphone

You guys helped so much with my last question, I figured I'd give you a shot at another. I have written an app with a theme that uses a dark blue glassy background and white / gray text and labels. The textfields in my app have clearcolor backgrounds and white texts and everything shows up very well. My only concern is that when you hold down a touch in a text box to get the magnification loupe, of course the white text shows up on a white background... which you can not read. Anybody got any ideas on how to implement a usable loupe here?

Unfortunately, the only "public" way I know how to change the loupe background is by setting textField.backgroundColor
I assume that since you're setting your backgrounds as clearColor, the magnifier defaults to white background, so the only way is to set your backgroundColor as something not clear.
I'm also assuming that since you did mention that you set your backgrounds a clear, that having it not be clear is not an option. So two ways I can think up in my mind about how to get around this is:
Assuming that the magnification lopue gets its background color by calling the backgroundColor implementation (and not some other obscure private API method): override the backgroundColor method and return a solid color.
Create your own loupe (probably not feasible)

I figured out a simple work around that achieved the desired effect. I also went through the full process of making my own loupe but since there is clear documentation on making your own loupe (see kiyoshi's answer), and this other method is ridiculously simple, I decided to document it here. It is basically just faking the clear background so that the white text shows up in the loupe. The background I am using for the view looks like blue smoke on a darker blue background:
alt text http://img231.imageshack.us/img231/9835/beforestatex.jpg
I took a screenshot of the simulator with the textfield visible and a black background so it would show up better:
alt text http://img193.imageshack.us/img193/9023/blackfieldx.jpg
Then I took that screenshot and made it semi transparent in photoshop, and overlayed my original background image to find exactly where the textfield appeared on the background:
alt text http://img266.imageshack.us/img266/9493/transparencyfullscreenx.jpg
Then I copied the exact pixels that would be used as the background of the textfield into a new PNG and saved that and set it as the the background image:
alt text http://img41.imageshack.us/img41/3450/textboxback.png
forwardToField.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:#"textboxback.png"]];
Keep in mind that the image will be repeated as a pattern within the loupe... so if you don't want to see the edges, simply make sure your textfield is larger than the loupe height and width.
Before:
alt text http://img196.imageshack.us/img196/2672/beforex.jpg
After:
alt text http://img23.imageshack.us/img23/2182/afterxd.jpg
I hope this helps somebody out there!

Actually its pretty feasible to create your own loop. Haven't tried subitting to apple yet so don't know how they feel about it.
Basic idea is override touches, use a timer to see how long the user has been touching the screen. The loupe is just a UIView that grabs as an image the view behind it and magnifies it.
Check out this article from Craftymind here
The article has you cache the entire image behind which is definitely faster, for rendering the loupe, but if you have stuff (i.e. textFields) that are constantly changing I've been able to render the loope image real-time without too much of a performance hit.

Related

How to add effects to UILabel

I've been searching for that many time ago and I can't find a solution. I have a animated label that crosses the screen of the iPhone (like the title of a song does in the Music app.Well, I'd like to add the "fade in/out" effect like the music app has. The easy solution is open Photoshop and create this simple image and then add it up to the label. Well, under the label I have an image with black backgroud. The image can be zoomed in and then the image with the fade in/out effect can be seen, and it doesn't look well. Is there any possibility to do this programatically? Thanks
PD: if there's another possibility rather than doing this programatically, I'll apreciate the answer as well.
Edit: Here's the image capture of the problem
I'll approach it in a non-programming way.
The image reference you gave us for the Music app you seem to be emulating has a different gradient than the one you drew in the second image.
If you notice in the image, the gradient has not fully completed its transition from clear to black before the words are cut off. I would say in photoshop run the gradient from clear to 80% alpha black and then draw a 100% alpha black rectangle to finish it off as per image. The white is just showing you what it looks like without the black background.
Now as for the zooming. Correct me if I am wrong, but it sounds like you want a viewing window for the image so that once you have zoomed into it, it will fade to either side, but still be viewable/movable in the center. This means that the image has to be zoom-able, but once you have zoomed the "fade in/out" should not be zoom-able.
Just make sure you aren't scaling the fader by keeping it separate from the scrollView of your background image.

Stop Repeating Background Image in UITextView

How do you stop an Image from repeating in an UITextView? What I want to achieve is have a UITextView that has text loaded from a .txt file (already works) and loads a preview image (already works) and finally I want the background to display my Logo at the top along with background colors I've made (all in 1 .png file), while when you scroll, the logo will go away and the rest of the background will scroll as well. My problem is that the Image repeats near the end of the text. If I make the image larger, my Logo stretches and looks sloppy, I'd like to keep the image at (0,0,480,However high the text is) and still keep the integrity of the logo in tact. I've tried searching the other similar questions but they all seem to want the repeat and I do not. Suggestions?
What about having a UIImageView that acts as a background image and setting the background for the textView to transparent - will it help?

How to know the background color of Pdf

Sometimes pdf might have a transparent background. And In my application I have given a option to choose background. So, in case of pdf with transparent background and background color black all things becomes black black so, any way to check or any key inside dictionary of pdf page that can help me? Any help will appreciated.
The easiest solution for you would be to remove black color from available background colors.
Generally, all pdf pages have transparent background and the white background color is set by the viewer application. It is possible to set a background color for each page. You can read all about it in Page Group under Transparency section of the PDF Reference.
It is also possible to show a background color for a page by setting 'BoxColorInfo' dictionary in the page dictionary with appropriate values.
But I am not sure what you can achieve by knowing what color a page background is, since black background is going to be a problem for PDFs with transparent pages anyways.
EDIT: Following is the paragraph from PDFReference i was trying to point you to:
Ordinarily, the page is imposed directly on an output medium, such as
paper or a display screen. The page group is treated as an isolated
group, whose results are then composited with a backdrop color
appropriate for the medium. The backdrop is nominally white, although
varying according to the actual properties of the medium. However,
some applications may choose to provide a different backdrop, such as
a checkerboard or grid to aid in visualizing the effects of
transparency in the artwork.
It says that most PDFs would have a transparent and it is your application which shows the background color. Hope this helps.

UI Button with Image Smaller than Touchable Area

I've not much response so am adding some more info.
My buttons are not rectangular, nor organised in a grid so I need a way of creating what looks like a button (and shows that it has been pressed visually, as per a standard UIButton) but where the touchable area is different to the image area.
I am using a transparent PNG and that element works fine. I've added the buttons in Interface Builder and am wondering if that is the problem.
However, if I change imageEdgeInsets, it distorts the image display, which is obviously not what I want.
Bizarrely, if I increase the dimemsions of the button, it doesn't change the image, but if I decrease them it does.
I have tried different combinations of mode (scale to fill etc), but to no avail.
I am aware that there is an image and background image property, but in IB there is only one.
Essentially, I don't understand how the geometry works and the Apple documentation doesn't seem to help.
Surely, I can't be the only person to try to do this. Any help would be warmly welcomed.
Many thanks,
Chris.
Try setting the buttons setting to Aspect Fit. This will fill the button with your image so a smaller image than the button size would leave the space around the image.
Also set the button type to custom.
In the end, I stumbled across Ole Begemann's Non-rectangular buttons class. It just does what I need - to be able to create buttons where the touchable area follows the visible element of a non rectangular image.
#Helium3 - thanks - that allowed me to use a larger touch area, bit not a smaller one.

How can I highlight an image on an iPhone?

I have a photo displayed on an iPhone. I would like to lower brightness of the photo at first, and when the user touches the photo, I would like to raise the brightness of the rectangular region near where the user touched, like this:
www.cottagearts.net/tut_images/tut_cropping_pse_06.jpg
Could anyone point me to a simple way of doing this?
While you can't actually adjust the brightness of the screen, you can put a semi-transparent image on the screen. I'd paint everywhere but where the user touched with an color that is black, but has X transparency, which is exactly what that image is showing that you linked to.
I'm no expert, but I've been trying to do something similar. You could implement this with layers. As Malfist suggested, you could make a black layer with a certain opacity and may the clicked part of it fully transparent or somesuch. Another option would be to do some image processing. I found an article here that I think will handle my highlighting issue:
http://arstechnica.com/apple/news/2009/03/iphone-dev-basic-image-processing-package.ars