Change background color of UIModalTransitionStyleFlipHorizontal - iphone

I would like to change the color behind the flip from white to a different color or picture. Is that possible?

Change the background colour of the UIWindow in MainWindow.nib. Either "black" or "clear" should both work (I think...)
It's one of the first things I do to any app, otherwise you get bits of white showing on a view rotation (in the very old days of 2.x there were huge patches of white; they've since masked off the screen edges during a rotation, but a few pixels still show through) and when you show/hide the status bar (e.g. for UIImagePicker) and stuff. Black looks a lot better than white for the window background.

Related

Why is UISegmentedControl turning the blue parts of my image to black?

Can anyone tell me why my segmentedcontrol changes colors of the image I set for the segments? When I step through the debugger the image contains black text and a blue dot. But when it is rendered in the simulator the dot is black and not blue:
Here is a screen shot of the view hierarchy showing the image I set on the segmented control with a blue dot and to the left the rendered view controller with the segmented control with the dot being black.
I assume this is related to the tint color and possibly how the control handles light and dark mode.
The funny thing is is I set the image to get an image from my image assets, it is fine. But this images was one that is dynamically generated with calls to UIGraphicsImageRenderer.
Thanks to input from Tom Harrington, the problem was I needed to apply the rendering mode to alwaysOriginal for my image - that was the trick!
let chatImage = UIImage.textEmbeded(image: scaledDotImage, string: "Chat", isImageBeforeText: false).withRenderingMode(.alwaysOriginal)

Swift iOS UI Advice

I am looking for some general advice and maybe some example code of what I am trying to accomplish if anyone knows of any for an iOS swift project. I would like to either:
A) Make the background, of the blue view, gray and only show a certain percent of the blue area.
OR
B) Overlay the gray area on top of the blue view and just keep making gray area bigger.
What I am trying to do is simulate battery power and show a battery.
I've considered using a progress bar and doing option A, but the blue area is NOT a solid color. Its actually an image. I've tried using an image for the progress bar, but the image needs to keep its dimensions. (Ex: If progress shows 20% it needs to show only 20% of the image or "blue area", but if you use an image as the progress bar it just shrinks the image and still shows 100% of it instead of just the 20% I need to show).
You can easily write a custom self-drawing UIView that will behave in exactly the way you describe. In other words, you tell your UIView a percentage, and it redraws itself with the blue on the left and the gray on the right. You can even draw the darker gray stroke outline shown in your drawings. All easily accomplished in code.
I like being able to lay things out visually and take advantage of autolayout. Here's how I would do this (in a nib/storyboard):
Place a UIView on your canvas and give it the gray background. Give it whatever autolayout constraints are appropriate for you.
Place a UIView inside the one from #1 and give it the blue background. Anchor it's left, top, and bottom to the gray parent view and give it whatever width (doesn't matter).
Add an outlet to that width constraint you made in #2.
Now all you have to do is modify the "constant" property of that width constraint to give you the desired "progress". So if your gray view is 100 wide and you want to present "20%" progress, then just do "yourWidthConstraint.constant = 20".

Core graphics color blending

I have a line of text which I want to display behind a CALayer, and when behind, then the text color should appear in a different color in the overlapping area.
The color of the text is black, and the text color should appear as white on the red layer when they overlap (they may both move around, so this needs to be continuously updated).
How may this be accomplished?
This can’t be done with any blend mode. You’ll need to render the text into the foreground layer in white by hand.
One trick you could try is to keep the white text always visible, but clipped by the layer that moves around using a second layer that also moves, set as the text’s mask.

Splashscreen ProgressBar in Eclipse RCP has "dirty" corners

I am using the RCP Splash Screen along with the built-in ProgressBar (AbsolutePositionProgressMonitorPart). The splash image has a blue background color, but the background of the progressbar seems to be white, which leads to some white corners.
(source: iachelini.de)
There is no "setBackground" on BasicSplashHandler nor does getContent().setBackground(Color) has any noticeable effect.
I don't want to be too picky, but since the splash is the first thing you see from the application, I think its very important to be tidy.
So, do you have any idea how to get rid of these corners?
Maybe it's not the color of the progress bar. Maybe it is the color of a component behind the progress bar? Have you tried to set the color of the parent components of the bar? Have you tried:
setBackgroundMode(SWT.INHERIT_FORCE);
?
Instead of trying to hack your way through the native component you might want to change the background image. Take an image where the white pixels do not disturb the first impression.

Loupe Magnification with White Text & Clear Background on 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.