How to flip a horizontal UIButton with another UIButton on the back?

I want a button that has another button on the back. When you press a button, it should flip horizontally and show another button. Apple did this in an ipod application. When you hear a song, you can click on the button on the right site of the navigation bar, and then flip the view, and you can see all the songs from the album. But interesting is that the button on the right side flips with a horizontal view. How can i do this?

alt text http://img51.imageshack.us/img51/585/welyrics2jpg.png

Thanks for the answer!

+4
source share
3 answers

I do not understand this.

My iPhone trainer did this for me a while ago. But I did not look at what he did.

So here is the code. .h

#import <UIKit/UIKit.h> @interface flipTesViewController : UIViewController { IBOutlet UIView *containerView; UIImageView *heads; UIImageView *tails; } -(IBAction)test; @end 

.m

 #import "flipTesViewController.h" @implementation flipTesViewController -(IBAction)test{ [UIView beginAnimations:nil context:nil]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:YES]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(test)]; [UIView setAnimationDuration:.5]; if(heads.tag==1){ [containerView addSubview:heads]; heads.tag=2; } else{ [containerView addSubview:tails]; heads.tag=1; } [UIView commitAnimations]; } - (void)viewDidLoad { [super viewDidLoad]; heads = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"NZHeads.png"]]; tails = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"NZTails.png"]]; [containerView addSubview:heads]; } //other method built in to view based template @end 
+5
source

In 3.x there is an easier way:

  • Make the "back side" as a UIViewController or one of its subclasses.
  • When you press the flip button, call

.

 backsideViewCtrler.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:backsideViewCtrler animated:YES]; 
+1
source
 -(void)viewDidLoad { UIButton *btn; = [UIButton buttonWithType:UIButtonTypeCustom]; btn.frame = CGRectMake(x, y, 60, 40); btn.backgroundColor = [UIColor clearColor]; [btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; btn.tag=count; [buttonWithTag setBackgroundImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal]; [btn setTitle:[NSString stringWithFormat:@"%d",btn.tag] forState:UIControlStateNormal]; [view_frame addSubview:btn]; [btn addTarget:self action:@selector(Click:)forControlEvents:UIControlEventTouchUpInside]; } //action - (IBAction)Click:(id)sender { UIButton *click_btn = (UIButton *)sender; NSLog(@"%d",click_btn.tag); UIButton *buttonWithTag = (UIButton *)[view_frame viewWithTag:click_btn.tag]; CATransition *animation = [CATransition animation]; animation.delegate = self; animation.duration = 1.0; animation.timingFunction = UIViewAnimationCurveEaseInOut; animation.fillMode = kCAFillModeForwards; animation.removedOnCompletion = NO; animation.type = @"oglFlip"; [buttonWithTag.layer addAnimation:animation forKey:nil]; [buttonWithTag setBackgroundImage:[UIImage imageNamed:@"1.png"] forState:UIControlStateNormal]; } 
0
source

All Articles