iOS7 tint color only works after presenting and dismissing another ViewController - uiviewcontroller

I'm having a very odd problem with tint color in iOS7.
When the ViewController that I'm having trouble with first loads, all of the tint is a light gray color, as if everything is inactive or behind a UIAlertView that has dimmed the screen. The buttons are still active and work just fine, but they are all gray. (I have the tint color set to orange, more on that in a bit).
Here's the odd part. If I present, and then immediately dismiss another ViewController, all of the orange tint appears and everything works as expected. That is the only way I have been able to get the tint to appear - nothing else seems to work.
I'm using the same basic code patterns throughout the app, and this problem really only affects one ViewController. This particular ViewController is presented UIModalPresentationFullScreen, and UIModalTransitionStyleCoverVertical, if those matter at all.
Here's how I'm setting tinting:
First, I have set a tint color on each view controller within interface builder, these settings are the same across both working and problematic VCs.
Next, I have set a tint color globally in my App Delegate like this:
[_window setTintColor:[UIColor orangeColor]];
The above two work on most of my ViewControllers, but not on all of them for some reason. For the ones that it was not working on, I've been using a handful of different techniques to get the tint color to work. For example:
self.view.tintColor = [UIColor orangeColor];
or
[_myUIBarButtonItem setTitleTextAttributes:
[NSDictionary dictionaryWithObject:[UIColor orangeColor]
forKey:NSForegroundColorAttributeName]
forState:UIControlStateNormal];
or to force a tintColor update:
[_myButtonOutlet setTitleColor:_cancelButtonOutlet.tintColor
forState:UIControlStateNormal];
Any ideas?

In iOS7, there are different tint behaviors you can choose from depending on what you want.
All you need to do is adjust the window's tintAdjustmentMode property to Normal in didFinishLaunching in app delegate.
self.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;

Related

Looking for a way to make three sliders affect an image (as a teaching tool)

I tried looking for this in search, but it is a lot of individual things packed together. What I am looking to make for my students is an interactive display of the triangle of exposure on a camera.
It has three sliders that show what happens with different settings. One is ISO (controls dark and lightness), another is shutter speed (which controls background blur/depth of field), and aperture, which controls motion blur. I was able to make a slider that effectively changes the test image in darkness. I am currently working on the slider for shutter speed.
I am wondering if the interaction between the sliders would be better accomplished through switching between PRE-PHOTOSHOPPED images by substitution, or using AS3 to accomplish changes on the fly. For instance, if they move the sliders for shutter speed and ISO at the same time, it gets dark AND has background blur. do I need to pre-photoshop every possible option, and switch symbols, or can I do it interactively with AS3?
Here is my code:
import flash.utils.getDefinitionByName;
import fl.motion.Color;
import fl.events.SliderEvent;
var myImageName1 = "blurback.jpg";
var classRef:Class = getDefinitionByName(myImageName1) as Class;
var instance:MovieClip = new classRef();
var c:Color=new Color();
var color = "#000000";
ISO.addEventListener(SliderEvent.CHANGE, sliderChanged);
aperture.addEventListener(SliderEvent.CHANGE, apertureChanged);
function sliderChanged(evt:SliderEvent):void {
tintClip();
}
/*
The 'setTint' method of of the Color class takes two parameters: tint
multiplier,
(a number between 0 and 1), and a tint color.
The tint multiplier, is determined by the positon of the slider, 'val'
and equals val/100.
The tint color, 'color', is determined by the color selected
in the picker.
*/
function tintClip():void {
var val:Number=ISO.value;
c.setTint(color,val/10);
kitty.transform.colorTransform=c;
}
function apertureChanged(evt:SliderEvent):void {
gotoAndPlay(2);
/*kitty.addChild(instance);*/
}
I am still experimenting with the second slider, so the gotoand play is a work in progress on substituting a pre-background-blurred image when the slider is slid.
Here is a pic of the final image, with the sliders named appropriately.
link: Final image
One is ISO (controls dark and lightness), another is shutter speed (which controls background blur/depth of field), and aperture, which controls motion blur.
ahem
All of the three settings influence the exposure value, making the image lighter or darker. Additionally:
ISO has an effect on noise in the image, which can severely degrade image quality
shutter speed is actually the one influencing motion blur and visibility of camera shake
aperture (among other things) influences depth of field
I am wondering if the interaction between the sliders would be better accomplished through switching between PRE-PHOTOSHOPPED images by substitution, or using AS3 to accomplish changes on the fly.
Neither of them is a good option.
Recreating the effects of the different settings with As3
realistically will take a lot more time (if possible at all) than simply having several images.
Recreating the effects in photoshop is probably easier as it is equipped with dozens of photo editing tools, but you'd still have to create the effect realistically.
Instead of photoshopping things, show your students the real deal:
Setup a subject in front of a background to show possible changes in depth of field
Include a solid color area where noise will be easy to see. This could be the background.
Add some motion, to show motion blur. A fan as a subject comes to mind.
Then take those images by varying the settings. Sure, with 5 different values each, you get 125 images. But you get real world example photos.
Keep the resolution low, so that the image files aren't too big. Process them by reducing resolution further to a reasonable size, say 800 x 600.
With the images created load them into your swf with the Loader class. The easiest way to keep track of them is to have a three dimensional array of Loader objects. Each slider then manipulates one index to change the image.

Changing UITabBar tint color after splash screen

I tried to read all the topics about uitabbar tint color but I couldn't find one that helped me.
I've no problem to change the tabbar tint color, but after launching the splash screen the tabbar color is for few instants white than it changes to the one I set on my application delegate in applicationDidFinishLaunching.
In the application delegate I first check the iOS version, I set the tabbar tint color, I call the splash screen that after 2.0 seconds dismisses itself presenting the uitabbarviewcontroller: the tint color is initially white then changes to the color I want.
Where is my error?
Thanx in advance
Fixed changing the modalTransitionStyle, it was set UIModalTransitionStyleCrossDissolve that caused the tabbar of the root view controller to be initially white, changed to UIModalPresentationCurrentContext.
Thanx

How do I make an object turn black, when a movie clip animation turns black?

I have a light bulb movie clip, where it glows and burns out. I want everything in the scene to turn black when it does burn out. Like objects, movieclips, and arrays. When the light bulb comes back on, I want the objects to turn back to their original color. How do I do this?
Simple way would be to just create a black rectangle and add it to the stage when you want the lights to go out.
When you want the lights back, just remove it from the stage.
You could also adjust the alpha of that black rectangle over time or tween it to have it gradually turn black. When the rectangle has alpha set to 0, everything else's color will be as if the lights are on. Alpha set to 1, would be complete darkness.
Update - now that you have changed the question in the comments of the question by adding details that would have been helpful from the beginning :
You can use ColorTransform to change the color of your fireflies to black. Google that or search that on this site for detail.
Also, you can do this effect in the IDE by setting one frame as normal, and in another frame tint it black using a color effect on the properties panel. (Not sure what version of the IDE you have, it might be labeled differently in earlier versions)

How to specify the "background" for BlendMode.ADD?

I am developing a flash game entirely in FlashDevelop, i.e., only with AS3 code.
I want to do the following: blend, as ADD (adding their colors), a couple of moving DisplayObjects, such that the blending occurs only between them, and not with anything else in the screen.
With no success, I've tried to do this: insert the moving DisplayObjects in a parent DisplayObject named container with blendMode as ADD, while all the rest of the game has blendMode NORMAL. I've also tried to set the blendMode of the moving DisplayObjects as ADD, with container.blendMode == NORMAL, with also no success.
Adobe's AS3 API mentions that the ADD Blend mode "Adds the values of the constituent colors of the display object to the colors of its background". How to control what this background is?
The background is anything with a lower depth than the movieclips that you're adding. So, whatever you had addChild()ed before those. It can also be the background color of the movie. Make sure that you are using a background color by using the backgroundColor parameter of the SWF tag (ie. [SWF(backgroundColor="#000000")]).
Everything in your game has to blend somehow with the DisplayObjects behind them, so it's hard to see what you need without seeing your specific example. At first hunch, try ADDing everything together in a single Sprite with a black background and then use BlendMode.LIGHTEN, BlendMode.SCREEN, or BlendMode.OVERLAY for that container Sprite.

calling presentModalViewController to show a view created programmatically

I've noticed that if I create a UIViewController-derived class programatically (without using a nib) to be displayed with a call to presentModalViewController, as the view slides in, it's actually transparent by default until the view covers the entire screen, after which point the 'opaqueness' seems to kick in and the view beneath the modalview is no longer visible.
If I create the view using a nib, it slides in as you'd expect, fully covering any views beneath with no transparency issues.
I noticed that the Apple examples tend to use a nib-based view for ModalViews, but wondered why. Perhaps I'm missing something.....
It was down to a foolish coding error on my part.
I realised I'd copied/pasted some code from elsewhere into my ViewDidLoad
self.view.backgroundColor = [UIColor colorWithRed:0.6 green:0.4 blue:0.2 alpha:0.3];
I'd set a value of 0.3 for alpha.
Set it to 1.0 and transparency issue goes away...
Problem solved