Как перевернуть UIButton по горизонтали с другой UIButton на задней стороне? - PullRequest
4 голосов
/ 17 января 2010

Я хочу кнопку, у которой есть другая кнопка на задней стороне.Когда вы нажимаете кнопку, она должна перевернуться в горизонтальном направлении и показать другую кнопку.Apple сделала это в Ipod-App.Когда вы слышите песню, вы можете нажать кнопку в правой части панели навигации, а затем перевернется вид, и вы увидите все песни из альбома.Но интересным моментом является то, что кнопка справа переворачивается с горизонтальным видом.Как я могу это сделать?

альтернативный текст http://img51.imageshack.us/img51/585/welyrics2jpg.png

Спасибо за ответ!

Ответы [ 3 ]

5 голосов
/ 17 января 2010

Я не понимаю этого атма.

Мой тренер по iPhone сделал это для меня некоторое время назад ... но я не смотрел на то, что он сделал.

Так вот код. .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
1 голос
/ 17 января 2010

На 3.х есть более простой способ:

  • Сделать «вид сзади» как UIViewController или один из его подклассов.
  • Когда нажата кнопка «перевернуть», позвоните

.

backsideViewCtrler.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:backsideViewCtrler animated:YES];
0 голосов
/ 16 апреля 2013
-(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];
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...