Flash effect using front facing camera Xcode - objective-c

So I have searched for hours on a solution to this and have attempted using filters with no success. I was wondering how can I create a flash effect using the front face camera but then modify the image so it looks like it added the flash as if it was using the back camera? I know a few apps such as snapchat have done this but I could not find a tutorial on how to achieve it. I have tried adjusting brightness, gamma & exposure with no success.
NOTE: I know there is no flash on a front camera for iOS.
EDIT: I am thinking it is possible by setting the screen brightness to the max, animating then going back to the previous brightness.

On an iOS device you take a screenshot when you press home + lock and the screen flashes white. Do you mean this effect? If so, try this:
Add a UIView with a white background color to your view hierarchy such that it covers the whole screen. Then, start an animation that fades the opacity of this view to zero. On completion, remove the view from its superview:
[UIView animateWithDuration: 0.5
animations: ^{
whiteView.alpha = 0.0;
}
completion: ^(BOOL finished) {
[whiteView removeFromSuperview];
}
];
If you want the entire screen to flash, add the white view to the application's UIWindow and set the frame accordingly. All buttons work all the time, if you add the white view just in the moment before the animation starts and remove it on completion - except during the short flash

I was able to make this work by increasing the system brightness right before the photo was taken, then resetting the value back. This would allow such brightness to reflect against someones face when in a dark room. If anyone wants to see the code, let me know. It is in Swift.

Related

iOS 7 + Auto Layout: Strange UIImageView behaviour

I've got a strange UIImageView behaviour:
I've got a UIViewController with an embedded UIImageView and a close button. Very basic stuff, done a thousand times. I didn't use Auto Layout that much in the past, but another view controller in the same Storyboard has nearly the same config and doesn't appear as strange as this specific one.
In my Storyboard the Controller looks like that:
...and on the device it looks like that:
That image is 1024x768, so it should be filled to the bounds. Content mode in the image view is Aspect fill. When i dismiss the view, i can see that the upper part of the image view must be hidden at the top with some negative Y or something.
I need Auto Layout in this storyboard, because it's an iPhone + iPad App with both orientations.
Has someone hat a behaviour like that before?
Thank you!
Edit:
Here is the layout panel:
First, get rid of the alignment constraints, they are not needed if you're already anchoring your view to every side with a set distance.
Second, check the mode property of your UIImageView in the interface builder. If the image was not big enough and you had it set for "TOP" instead of, say, "aspect fill", you'd see something like this even though the view is actually covering the whole screen.
I'm sorry that I have to say this, but it was, as you certainly thought, my own fault.
The problem was that I made a photo with the iPad, and the iPad can be used in both orientations in this app. The photo was taken and was then used for an own view that allows the user to put annotations on the image.
The image gets then saved, and that was were the problem occured: I call
UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, 0.0);
The landscape image was now taken into a portrait frame. After adjusting this and only allowing portrait mode, everything worked well.
Thanks anyways for your answers. And sorry for asking a question when the problem was another one and my own fault.

Animating a circle UIImageView to disappear

If I have a UIImageView of a circle, how could Core Animation make it disappear like in this question?
How to use CoreAnimation to animate a circle like a clock countdown
Create a CAShapeLayer. Set its path to your “clock” shape. Set it as the layer mask of your image view (e.g. imageView.layer.mask = shapeLayer).
Then you can try using a CAKeyframeAnimation to animate the shape layer's path, but I suspect the results won't be pleasing. Instead you'll probably want to use a CADisplayLink as a timer and update the shape layer's path every time it fires.
What you are looking for is known as a "clock wipe" transition.
David is pointing you in the right direction. I have a sample project on Github that shows exactly what you are looking for:
iOS Core Animation Demo
When you run the app, click on the "Mask Animation" button. It does what you're talking about. It shows an image view with a clock wipe, and then hides it again. It would be a simple matter to switch it around to have the image fully visible at first and then animate a clock wipe to hide it.

UISlider background disappears

I use UISlider for video player to track and change the location of the playback.
It seems that when ever I change the slider.value from code, the background line of the slider disappears.
It changes from this:
to this:
(I added the gray background color)
What can cause this issue?
Solved.
As trojanfoe suggested, I looked at this question:
iOS - iPhone : UISlider track image disappearing randomly
In simple words: I used [UISlider setValue:animated:] and made sure I don't get NaN, which was the real problem.

How to toggle OpenGL fullscreen rendering in Lion?

When my window goes fullscreen, what must I do to obtain an OpenGL rendering context (or change the existing one) for the new higher resolution view?
Right now in the window delegate I have
- (NSSize)window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)proposedSize {
return [theOpenGLView bounds].size;
}
Which is fairly pointless as I just get the same sized window on a massize linen background.
I tried returning [[NSScreen mainScreen] frame].size but this just put my OpenGL window in the corner and the rest of the screen was covered by the greyish view background. I tried updating my glViewport and projection matrix and calling [myNSOpenGLContext update] but this didn't work either.
All the apple documentation seems to be for the old fullscreen system. I would appreciate if someone could enumerate the steps required to do this properly.
The problem was that my view wasn't autoresizing, so although the window took up the whole screen, the view was fixed. Now I have to figure out how to make the transition not look horrendous…

uiscrollview and uibutton behaves transparent for touch events

I have a custom subclass of UIView and a full screen UIButton with a background image on it as you can see in the image,
on the right side, there is a UIView with a UIImageView on it and some other not important labels and buttons. The important part is, there are two scrollviews on that UIView and at the run time, i add UIButtons ( not small ones, 200 x 100 ) on those scrollviews with vertical scrolling enabled.
The situation is really very complex so i will write as items what happens in different conditions. In my application, there are 10 of these complete screens, on a custom subclass of UIView and i use UIPanGestureRecognizer to scroll from one to other.I have a good reason not to use a scrollview for this. All the windows ( the below image, not UIWindow ) populates their content in a loop, so the running code is exact same for all of them and all of them are being created from the same .xib file. And the last information, the bigger UIButton that covers all the window has an action for touchupinside and the smaller buttons in scrollviews have their own touchupinside selectors.
Some of my windows works perfectly, if i touch anywhere on the screen, the bigger buttons action is called, if i touch and drag, the scroll works and i navigate to the next / previous window, if i touch on smaller buttons in scrollviews, their actions fired and lastly i can perfectly scroll within those buttons.
Some of my windows, when i try to scroll the scrollviews, the bigger windows pangesturerecognizer catchs this event not the small scrollviews, and if i touch the small button in that scroll view, the bigger buttons event is fired ( it pass all through uibutton > uiscrollview > uiimageview > uiview to the uibutton at the button like they dont exist )
if i replace the right container view some other position on the big uibutton, it randomly works well or not, sometimes one of the scrollviews works well and the other not.
it has a consistent behaviour, if on a one position, it works, it allways works, and if it not, it never does.
Again, all the views and subclasses have their userinteraction enabled yes, the opposite is already imposible because the behaviour changes only acording to position of container view on the big uibutton and also changes acording to big uibuttons background image.
I've placed a touchesBegan method for just test purposes, when the touches does not work as expected, the event fired with touch.view is the container of the big button, even if i touch on a small button within the scrollviews.
I've spend two days already for that and no result.What can cause this behaviour ?
EDIT : After krumelur's comment I've changed my focus from configuration of those views to animation i give to the container views, and i've noticed that, the problem is about the animation, i'm adding the the code part that animates all ten windows and behaves like a custom scrollview. All windows have their custom layer class and when i catch pangesture recognizer i move windows on the screen with following code. items in that code is an array which holds layers of all the windows. The animation causes that strange situation but i couldnt figure out yet..
- (void)layoutSublayers {
[super layoutSublayers];
[CATransaction begin];
[CATransaction setDisableActions:YES];
float angleDelta = 2 * M_PI / [items count];
float a = angle;
for (UIBaseLayer *l in items) {
l.position = self.position;
CATransform3D translation = CATransform3DMakeTranslation(cosf(a)*(radius.x), 1.0, (sinf(a)*radius.y) - radius.y*1.0);
float dailyAngle = (M_PI_2 - a);
CATransform3D rotation = CATransform3DMakeRotation(dailyAngle, 0, 1.0, 0);
CATransform3D t = CATransform3DConcat(rotation, translation);
l.transform = t;
a += angleDelta;
}
[CATransaction commit];}
http://img836.imageshack.us/img836/296/screenshot20111215at013.png
bringSubviewToFront did not work reliably on 5.0 (on 5.1 the hack was not needed)
I had to add a bigger transparrent UIButton around the button that behaved as if it was disabled to fix this on iOS prior to 5.1.
At last I've figured out that, even I send back views with CATransform3DMakeTranslation and layer.zPosition settings, touch events goes to views according to their frame position. The views that aren't currently even seen (overlayed by others) still catch touches. Writing just one line of code ([self.superview bringSubviewToFront:self]) for the view that is currently on screen solved the problem.
For testing this and understanding what I'm talking about, I've made simple test application that has only two buttons on it.
The blue and yellow buttons.The blue button overlays the yellow button so you can only see the blue one at the beginning.
On the touch up inside code for the blue button, I just send it back with buttons.layer.zPosition = -1. After this, there is no visible part of the blue button remains on screen, instead I see just the yellow button now, but when I touch the yellow button (or I think I am touching it) still blue buttons touch up inside code runs.
I'm not sure if this is the desired logic but it does not seem reasonable to me.
As I mentioned above, writing [blueButton.superview sendSubviewToBack:blueButton] while setting its layers zPosition to -1 works as expected.