iphone view overlay - iphone

I have a client who recently requested this:
My thoughts were that the text could be better displayed on the back of a flipover view and that it looks like it could be an issue in the approval process. Is There any way to even do this, do I even want to try? Are there resources you can share?
Thanks in advance.
EDIT: I should clarify that the NavigationBar and the Table would slide over when taping the picture behind. One tap would make it show and the other tap would make the bar and the table hide.

This is actually pretty good. It's often hard to get clients to give you requirements, and this at least shows you what they're trying to achieve. I'd spend some time reworking the UI so that it will be acceptable in the app store (assuming you're going to publish there) and perhaps more in keeping with the normal use of iOS UI elements. Prepare to give your client a bit of an explanation about why this particular design leaves something to be desired, but try to come up with a design that they'll agree is obviously better. (There's plenty of room for improvement here, so it shouldn't be too hard.)
If your client is absolutely wedded to this exact UI, it might be time to find a new client. But if they're reasonable, thoughtful, and a little bit flexible, this might be the beginning of a nice app.

You can do this. Put the picture (UIImageView) inside a wrapper UIView. Put the text in a UITextView also in the wrapper UIView. Then animate a flip transition between them that brings whichever one you want to the bottom of the subview stack.
You can check for potential UI violations in Apple's HIG: http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/Introduction/Introduction.html

+(id)showAlert{
UIViewController *controller = [[UIViewController alloc] initWithNibName:#"Overlay" bundle:nil];
Overlay *alert = (Overlay*)controller.view;
//alert.iTag = iiTag;
alert.tag = iiTag;
return alert;
}
-(void)addAnimation{
self.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3/1.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(bounce1AnimationStopped)];
self.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
[UIView commitAnimations];
}
- (void)bounce1AnimationStopped {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3/2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(bounce2AnimationStopped)];
self.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9,0.9);
[UIView commitAnimations];
}
- (void)bounce2AnimationStopped {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3/2];
self.transform = CGAffineTransformIdentity;
[UIView commitAnimations];
}
- (CGAffineTransform)transformForOrientation {
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (orientation == UIInterfaceOrientationLandscapeLeft) {
return CGAffineTransformMakeRotation(M_PI*1.5);
} else if (orientation == UIInterfaceOrientationLandscapeRight) {
return CGAffineTransformMakeRotation(M_PI/2);
} else if (orientation == UIInterfaceOrientationPortraitUpsideDown) {
return CGAffineTransformMakeRotation(-M_PI);
} else {
return CGAffineTransformIdentity;
}
}
-(void)stopAnimatton{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelay:2.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
self.transform = CGAffineTransformMake(00.1, 00.1,0.001, 0.001, 0.001, 0.001);
[UIView commitAnimations];
}

Related

How to customize UIAlert View..?

I have customized the UIViews by adding images to make it look like radio button or check boxes, but for my spec I want to make the UIAlertView look like this...
Can anyone suggest how to do this?
Thanks!
You can design custom view and can give animation to it as alert view using this code
-(void)initialDelayEnded
{
alert_upload.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
alert_upload.alpha = 1.0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1/1.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(bounce1AnimationStopped)];
alert_upload.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
[UIView commitAnimations];
}
- (void)bounce1AnimationStopped {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5/2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(bounce2AnimationStopped)];
alert_upload.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
[UIView commitAnimations];
}
- (void)bounce2AnimationStopped {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5/2];
alert_upload.transform = CGAffineTransformIdentity;
[UIView commitAnimations];
}
alert_upload is UIView.
There’s many previous questions about this topic, one of them links this component that lets you create custom alerts and action sheets. Might be a good way to start.
You can create your own customized alert views, Apple wont reject it until unless user interaction.

UIView shows the subview view sometimes?

I am developing iOS game and need custom animation so I am using this method
CGRect basketTopFrame = mainScreenView.frame;
basketTopFrame.origin.x = 320;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
mainScreenView.frame = basketTopFrame;
[UIView commitAnimations];
in the .h file I have declared mainScreen like this
IBOutlet UIView *mainScreenView;
So in the IB I have put UIView in the view in the interface and hooked it up with mainScreenView
So in the mainViewScreen the view sometimes shows up sometimes doesn't (works on the 2nd try) however when I remove the animation code it works perfectly fine..I don't know what is happening any help would be appreciated thanks
edit
this is how I added the view
MainScreen *mainScreen = [[MainScreen alloc]initWithNibName:#"MainScreen" bundle:nil];
[mainScreenView addSubview:mainScreen.view];
I tried it in a sandbox project, and this worked for me:
- (IBAction)buttonTouched:(id)sender {
myView.transform = CGAffineTransformMakeTranslation(-320, 0);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
myView.transform = CGAffineTransformMakeTranslation(0,0);
[UIView commitAnimations];
}
Looks like you are trying to move something off screen. An easier way is to do this
[UIView beginAnimations:#"UIBase Hide" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
mainScreenView.transform = CGAffineTransformMakeTranslation(320,0); //slide view to the right.
[UIView commitAnimations];
note: using 320 on the Translation wont move the view to the 320th pixel of the screen rather it moves your view 320px to the right. So if your mainScreenView is at origin.x = 100. After this translation it is now at 420.
To move it back do
self.transform = CGAffineTransformIdentity;

Trouble with UIView Animations - performing the same animation more than once doesn't work

I need to flip a card and then flip it back. I have written code to do that with no trouble. The trouble comes because users can flip this card back and forth as many times as they want, and it seems that the effect is cumulative. On the second try, the card spins like a top. I'm not completely surprised, as there only seems to be a way to add animation, not clear one from the view. Is there a way to 're-set' a UIView of any animations I had previously committed? Is there a way to capture it and re-use it without committing a new one? Or am I missing something obvious? This is my code:
if (self.flipped) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self
cache:YES];
[imageView removeFromSuperview];
[UIView commitAnimations];
self.flipped = NO;
} else {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self
cache:YES];
[self addSubview:imageView];
[UIView commitAnimations];
self.flipped = YES;
}
Thanks for reading.
To cancel all ongoing animations:
#import <QuartzCore/QuartzCore.h>
...
[view.layer removeAllAnimations];
To start a new animation that kills existing animations, if any, and starts the movement from wherever the view currently is — which I think is what you want:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
... and the rest of it ...
[UIView commitAnimations];
Hopefully one of those will solve your problem.
Whatever your "self" is, put it in a containing view called foo, and then change your setAnimation... line to this:
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:foo
cache:YES];

fliping view continiously

this my code
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5];
if ([sender tag] == 1) {
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:placeholder cache:YES];
}
else {
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
}
if (view1OnTop) {
[view1 removeFromSuperview];
[placeholder addSubview:view2];
}
else {
[view2 removeFromSuperview];
[placeholder addSubview:view1];
}
[UIView commitAnimations];
view1OnTop = !view1OnTop;
i want to continuously flip the view, for say some duration 1 min.
it should be continuously flipping.
how can i do it.
what i m trying to is, i want a view, which should be continuously flipping for some particular amount of time.
how can i achieve this?
regards
Apart from the flipping animation, which I presume you have working, you need to initiate a new animation when the current one is finished.
Before [UIView commitAnimations], do this:
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(animationDone:finished:context:)];
add a function
-(void)animationDone:(NSString*)id finished:(NSNumber*)n context:(void*)context
and let that fire the next round.
edit: you do this by putting in the code to fire an animation, so the typical block from [UIView beginAnimations...] to [UIView commitAnimations]. The better solution of course is to put the animation starting code in a separate function, so the outline will look like:
...
[self startAnimationLoop];
...
-(void)startAnimationLoop
{
[UIView beginAnimtions...];
// do the animation stuff
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(animationDone:finished:context:)];
[UIView commitAnimations];
}
-(void)animationDone:(NSString*)id finished:(NSNumber*)n context:(void*)context
{
[self startAnimationLoop];
}
to make it go back/forth, add some state variable, or create 2 sets of these functions which call eachother (startAnimationLoop1 and startAnimationLoop2, each one firing the other when done)

Any way of changing the duration of zoomToRect for UIScrollView?

Is there any way to specify a duration for the animation of [UIScrollView zoomToRect:zoomRect animated:YES]?
At the moment it's either fast animated:YES or instant animated:NO.
I'd like to specify a duration, eg [UIScrollView setAnimationDuration:2]; or something similar.
Thanks in advance!
Use the UIView's animations.
It's a bit long to explain, so I hope this little example will clear things up a bit.
Look at the documantation for further instructions
[UIView beginAnimations: nil context: NULL];
[UIView setAnimationDuration: 2];
[UIView setAnimationDelegate: self];
[UIView setAnimationDidStopSelector: #selector(revertToOriginalDidStop:finished:context:)];
expandedView.frame = prevFrame;
[UIView commitAnimations];
It's from a project I'm currently working on so it's a bit specific, but I hope you can see the basics.
I've had luck with this method in a UIScrollView subclass:
- (void)zoomToRect:(CGRect)rect duration:(NSTimeInterval)duration
{
[self setZoomLimitsForSize:rect.size];
if (duration > 0.0f) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:duration];
}
[self zoomToRect:rect animated:NO];
if (duration > 0.0f)
[UIView commitAnimations];
[self zoomToRect:rect animated:(duration > 0.0f)];
}
It's kinda cheating, but it seems to mostly work. Occasionally it does fail, but I don't know why. In this case it just reverts to the default animation speed.
Actually these answers are really close to what I ended up using but I'll post mine separately since it is different. Basically the zoomToRect does not work correctly if the destination zoomScale is the same as the current one.
You could try to scrollToRect but I did not have any luck with that.
Instead just use the contentOffset and set it to the zoomRect.origin and nest that in the animation block.
[UIView animateWithDuration:duration
delay:0.f
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
if (sameZoomScale) {
CGFloat offsetX = zoomRect.origin.x * fitScale;
CGFloat offsetY = zoomRect.origin.y * fitScale;
[self.imageScrollView setContentOffset:CGPointMake(offsetX, offsetY)];
}
else {
[self.imageScrollView zoomToRect:zoomRect
animated:NO];
}
}
completion:nil];