2012-04-05 74 views
6

我想开发一个应用程序,其菜单看起来像ios Linkedin应用程序之一。这样的(左画面)LinkedIn菜单iPhone应用程序

enter image description here

有4个瞥见被关联到四个主要视图(微缩)。 微缩模块总是显示视图的更新状态。

我想知道我们可以做这样的菜单吗?

在此先感谢您的帮助!

塞巴斯蒂安;)


那么,为什么你把4的UIView在其他的UIView,而不是直接在UIViewController的? 你谈到了按钮,但在你的例子中只有UIView?我想知道4个按钮是否在4个视图中,并且为了应用转换而是透明的。

您是否有转换的代码示例?

非常感谢您的帮助!

+1

......你要我们......究竟是什么? – badgerr 2012-04-05 14:38:44

+0

对不起!我忘了问题! – 2012-04-05 14:48:08

回答

1
- (void)viewDidLoad { 
[super viewDidLoad]; 
[self.navigationItem setTitle:@"About us"]; 

presentationViewController = [[PresentationViewController alloc] initWithNibName:@"PresentationViewController" bundle:nil]; 
secteursViewController = [[SecteursViewController alloc] initWithNibName:@"SecteursViewController" bundle:nil]; 
engagementsViewController = [[EngagementsViewController alloc] initWithNibName:@"EngagementsViewController" bundle:nil]; 
interviewsViewController = [[InterviewsViewController alloc] initWithNibName:@"InterviewsViewController" bundle:nil]; 

presentationApercu = presentationViewController.view; 
secteursApercu = secteursViewController.view;  
videosApercu = interviewsViewController.view; 
engagementsApercu = engagementsViewController.view; 

presentationApercu.transform = CGAffineTransformMakeScale(1/(320./107), 1/(367./122.)); 
presentationApercu.frame = CGRectMake(27., 18., presentationApercu.frame.size.width, presentationApercu.frame.size.height); 

secteursApercu.transform = CGAffineTransformMakeScale(1/(320./107), 1/(367./122.)); 
secteursApercu.frame = CGRectMake(185., 18., secteursApercu.frame.size.width, secteursApercu.frame.size.height); 

videosApercu.transform = CGAffineTransformMakeScale(1/(320./107), 1/(367./122.)); 
videosApercu.frame = CGRectMake(27., 196., videosApercu.frame.size.width, videosApercu.frame.size.height);; 

engagementsApercu.transform = CGAffineTransformMakeScale(1/(320./107), 1/(367./122.)); 
engagementsApercu.frame = CGRectMake(185., 196., engagementsApercu.frame.size.width, engagementsApercu.frame.size.height); 

presentationApercu.tag = 1; 
secteursApercu.tag = 2; 
videosApercu.tag = 3; 
engagementsApercu.tag = 4; 

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
[tap setNumberOfTapsRequired:1]; 
[presentationApercu addGestureRecognizer:tap]; 
[tap release]; 

tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
[tap setNumberOfTapsRequired:1]; 
[secteursApercu addGestureRecognizer:tap]; 
[tap release]; 

tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
[tap setNumberOfTapsRequired:1]; 
[videosApercu addGestureRecognizer:tap]; 
[tap release]; 

tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
[tap setNumberOfTapsRequired:1]; 
[engagementsApercu addGestureRecognizer:tap]; 
[tap release]; 

[self.view addSubview:presentationApercu]; 
[self.view addSubview:secteursApercu]; 
[self.view addSubview:videosApercu]; 
[self.view addSubview:engagementsApercu]; 

} 


#pragma mark - IBActions 

- (void)zoomReverse { 
[self.navigationItem setLeftBarButtonItem:nil]; 
UITapGestureRecognizer *tap = nil; 

switch (tagEnCours) { 
    case 1: 
     [self.view bringSubviewToFront:presentationApercu]; 

     tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
     [tap setNumberOfTapsRequired:1]; 
     [presentationApercu addGestureRecognizer:tap]; 
     [tap release]; 

     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

     presentationApercu.transform = CGAffineTransformMakeScale(1/(320./107), 1/(367./122.)); 
     presentationApercu.frame = CGRectMake(27., 18., presentationApercu.frame.size.width, presentationApercu.frame.size.height); 

     [UIView commitAnimations]; 

     break; 

    case 2: 
     [self.view bringSubviewToFront:secteursApercu]; 

     tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
     [tap setNumberOfTapsRequired:1]; 
     [secteursApercu addGestureRecognizer:tap]; 
     [tap release]; 

     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

     secteursApercu.transform = CGAffineTransformMakeScale(1/(320./107), 1/(367./122.)); 
     secteursApercu.frame = CGRectMake(185., 18., secteursApercu.frame.size.width, secteursApercu.frame.size.height); 

     [UIView commitAnimations]; 

     break; 

    case 3: 
     [self.view bringSubviewToFront:videosApercu]; 

     tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
     [tap setNumberOfTapsRequired:1]; 
     [videosApercu addGestureRecognizer:tap]; 
     [tap release]; 

     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

     videosApercu.transform = CGAffineTransformMakeScale(1/(320./107), 1/(367./122.)); 
     videosApercu.frame = CGRectMake(27., 196., videosApercu.frame.size.width, videosApercu.frame.size.height); 

     [UIView commitAnimations]; 

     break; 

    case 4: 
     [self.view bringSubviewToFront:engagementsApercu]; 

     tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
     [tap setNumberOfTapsRequired:1]; 
     [engagementsApercu addGestureRecognizer:tap]; 
     [tap release]; 

     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

     engagementsApercu.transform = CGAffineTransformMakeScale(1/(320./107), 1/(367./122.)); 
     engagementsApercu.frame = CGRectMake(185., 196., engagementsApercu.frame.size.width, engagementsApercu.frame.size.height); 

     [UIView commitAnimations]; 

     break; 

    default: 
     break; 
} 
} 

- (void)zoomAction:(UITapGestureRecognizer *)sender { 
[self.navigationItem setLeftBarButtonItem:[[[UIBarButtonItem alloc] initWithTitle:@"About us" style:UIBarButtonItemStyleDone target:self action:@selector(zoomReverse)] autorelease]]; 
tagEnCours = sender.view.tag; 
switch (sender.view.tag) { 
    case 1: 
     [self.view bringSubviewToFront:presentationApercu]; 
     [presentationApercu removeGestureRecognizer:[presentationApercu.gestureRecognizers objectAtIndex:0]]; 

     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

     presentationApercu.transform = CGAffineTransformIdentity; 
     presentationApercu.frame = CGRectMake(0., 0., presentationApercu.frame.size.width, presentationApercu.frame.size.height); 

     [UIView commitAnimations]; 

     break; 

    case 2: 
     [self.view bringSubviewToFront:secteursApercu]; 
     [secteursApercu removeGestureRecognizer:[secteursApercu.gestureRecognizers objectAtIndex:0]]; 

     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

     secteursApercu.transform = CGAffineTransformIdentity; 
     secteursApercu.frame = CGRectMake(0., 0., secteursApercu.frame.size.width, secteursApercu.frame.size.height); 

     [UIView commitAnimations]; 
     break; 

    case 3: 
     [self.view bringSubviewToFront:videosApercu]; 
     [videosApercu removeGestureRecognizer:[videosApercu.gestureRecognizers objectAtIndex:0]]; 

     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

     videosApercu.transform = CGAffineTransformIdentity; 
     videosApercu.frame = CGRectMake(0., 0., videosApercu.frame.size.width, videosApercu.frame.size.height); 

     [UIView commitAnimations]; 
     break; 

    case 4: 
     [self.view bringSubviewToFront:engagementsApercu]; 
     [engagementsApercu removeGestureRecognizer:[engagementsApercu.gestureRecognizers objectAtIndex:0]]; 

     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

     engagementsApercu.transform = CGAffineTransformIdentity; 
     engagementsApercu.frame = CGRectMake(0., 0., engagementsApercu.frame.size.width, engagementsApercu.frame.size.height); 

     [UIView commitAnimations]; 
     break; 

    default: 
     break; 
} 
} 
+0

这是我的代码。 – 2012-04-13 12:43:17

+0

我不明白,我试图把这样一个滚动视图,一切似乎没有问题,继续动摇,你看得够好。 该帖子的ViewController有一些特别的东西?他们的背景是完整的? – WhiteTiger 2012-04-13 13:11:49

0

我认为如下本申请的结构:

UIViewController 
    | UIView 
    | UIView 
    | UIView 
    | UIView 
    | UIView 

第一个包含主视图控制器(包含4个按钮的一个),这些都是由(I假设)还原变换,然后将视图由次要视图叠加,第二个要求。

这是我的想法,因为如果您尝试滚动表格并立即返回,即使在缩略图视图滚动。

希望有一些帮助。

+0

那么,为什么你把4个UIView放在另一个UIView中,而不是直接放在UIViewController上呢?你谈到了按钮,但在你的例子中只有UIView?我想知道4个按钮是否在4个视图中,并且为了应用转换而是透明的。 您是否有转换的代码示例? 非常感谢您的帮助! – 2012-04-10 14:11:03

+0

我举了一个例子,我假定系统是我提供的系统,但这不是我的想法。例如,在这一刻,我不能让你,我在工作,但只有5分钟,我试图拿下草图 – WhiteTiger 2012-04-10 14:16:03

+0

好吧,我正在等待这个例子。 非常感谢。 – 2012-04-11 10:33:16

0

认为这是一个草案,从中汲取灵感:

//.h 
#import <UIKit/UIKit.h> 

@interface ViewController : UIViewController 

@end 

//.m 
#import "ViewController.h" 

@interface ViewController() 

@property (nonatomic, strong) UIView *v1; 
@property (nonatomic, strong) UIView *v2; 
@property (nonatomic, strong) UIView *v3; 
@property (nonatomic, strong) UIView *v4; 

@end 

@implementation ViewController 

@synthesize v1 = _v1; 
@synthesize v2 = _v2; 
@synthesize v3 = _v3; 
@synthesize v4 = _v4; 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    _v1 = [[UIView alloc] initWithFrame:self.view.bounds]; 
    _v2 = [[UIView alloc] initWithFrame:self.view.bounds];  
    _v3 = [[UIView alloc] initWithFrame:self.view.bounds]; 
    _v4 = [[UIView alloc] initWithFrame:self.view.bounds]; 

    [_v1 setBackgroundColor:[UIColor redColor]]; 
    [_v2 setBackgroundColor:[UIColor yellowColor]]; 
    [_v3 setBackgroundColor:[UIColor blueColor]]; 
    [_v4 setBackgroundColor:[UIColor greenColor]]; 

    _v1.transform = CGAffineTransformMakeScale(1/(320./140.), 1/(460./210.)); 
    _v1.frame = CGRectMake(10., 10., _v1.frame.size.width, _v1.frame.size.height); 

    _v2.transform = CGAffineTransformMakeScale(1/(320./140.), 1/(460./210.)); 
    _v2.frame = CGRectMake(170., 10., _v2.frame.size.width, _v2.frame.size.height); 

    _v3.transform = CGAffineTransformMakeScale(1/(320./140.), 1/(460./210.)); 
    _v3.frame = CGRectMake(10., 240., _v3.frame.size.width, _v3.frame.size.height); 

    _v4.transform = CGAffineTransformMakeScale(1/(320./140.), 1/(460./210.)); 
    _v4.frame = CGRectMake(170., 240., _v4.frame.size.width, _v4.frame.size.height); 

    _v1.tag = 1; 
    _v2.tag = 2; 
    _v3.tag = 3; 
    _v4.tag = 4; 

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
    [tap setNumberOfTapsRequired:1]; 
    [_v1 addGestureRecognizer:tap]; 
    [tap release]; 

    tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
    [tap setNumberOfTapsRequired:1]; 
    [_v2 addGestureRecognizer:tap]; 
    [tap release]; 

    tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
    [tap setNumberOfTapsRequired:1]; 
    [_v3 addGestureRecognizer:tap]; 
    [tap release]; 

    tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
    [tap setNumberOfTapsRequired:1]; 
    [_v4 addGestureRecognizer:tap]; 
    [tap release]; 

    [self.view addSubview:_v1]; 
    [self.view addSubview:_v2]; 
    [self.view addSubview:_v3]; 
    [self.view addSubview:_v4]; 

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    [btn setFrame:CGRectMake(10, 10, 100, 30)]; 
    [btn setTitle:@"Close" forState:UIControlStateNormal]; 
    btn.tag = 1; 
    [btn addTarget:self action:@selector(zoomReverse:) forControlEvents:UIControlEventTouchUpInside]; 
    [_v1 addSubview:btn]; 

    btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    [btn setFrame:CGRectMake(10, 10, 100, 30)]; 
    [btn setTitle:@"Close" forState:UIControlStateNormal]; 
    btn.tag = 2; 
    [btn addTarget:self action:@selector(zoomReverse:) forControlEvents:UIControlEventTouchUpInside]; 
    [_v2 addSubview:btn]; 

    btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    [btn setFrame:CGRectMake(10, 10, 100, 30)]; 
    [btn setTitle:@"Close" forState:UIControlStateNormal]; 
    btn.tag = 3; 
    [btn addTarget:self action:@selector(zoomReverse:) forControlEvents:UIControlEventTouchUpInside]; 
    [_v3 addSubview:btn]; 

    btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    [btn setFrame:CGRectMake(10, 10, 100, 30)]; 
    [btn setTitle:@"Close" forState:UIControlStateNormal]; 
    btn.tag = 4; 
    [btn addTarget:self action:@selector(zoomReverse:) forControlEvents:UIControlEventTouchUpInside]; 
    [_v4 addSubview:btn]; 
} 

- (void)zoomReverse:(UIButton *)sender { 
    UITapGestureRecognizer *tap = nil; 

    switch (sender.tag) { 
     case 1: 
      [self.view bringSubviewToFront:_v1]; 

      tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
      [tap setNumberOfTapsRequired:1]; 
      [_v1 addGestureRecognizer:tap]; 
      [tap release]; 

      [UIView beginAnimations:nil context:NULL]; 
      [UIView setAnimationDuration:1]; 
      [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

      _v1.transform = CGAffineTransformMakeScale(1/(320./140.), 1/(460./210.)); 
      _v1.frame = CGRectMake(10., 10., _v1.frame.size.width, _v1.frame.size.height); 

      [UIView commitAnimations]; 

      break; 

     case 2: 
      [self.view bringSubviewToFront:_v2]; 

      tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
      [tap setNumberOfTapsRequired:1]; 
      [_v2 addGestureRecognizer:tap]; 
      [tap release]; 

      [UIView beginAnimations:nil context:NULL]; 
      [UIView setAnimationDuration:1]; 
      [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

      _v2.transform = CGAffineTransformMakeScale(1/(320./140.), 1/(460./210.)); 
      _v2.frame = CGRectMake(170., 10., _v2.frame.size.width, _v2.frame.size.height); 

      [UIView commitAnimations]; 

      break; 

     case 3: 
      [self.view bringSubviewToFront:_v3]; 

      tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
      [tap setNumberOfTapsRequired:1]; 
      [_v3 addGestureRecognizer:tap]; 
      [tap release]; 

      [UIView beginAnimations:nil context:NULL]; 
      [UIView setAnimationDuration:1]; 
      [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

      _v3.transform = CGAffineTransformMakeScale(1/(320./140.), 1/(460./210.)); 
      _v3.frame = CGRectMake(10., 240., _v3.frame.size.width, _v3.frame.size.height); 

      [UIView commitAnimations]; 

      break; 

     case 4: 
      [self.view bringSubviewToFront:_v4]; 

      tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomAction:)]; 
      [tap setNumberOfTapsRequired:1]; 
      [_v4 addGestureRecognizer:tap]; 
      [tap release]; 

      [UIView beginAnimations:nil context:NULL]; 
      [UIView setAnimationDuration:1]; 
      [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

      _v4.transform = CGAffineTransformMakeScale(1/(320./140.), 1/(460./210.)); 
      _v4.frame = CGRectMake(170., 240., _v4.frame.size.width, _v4.frame.size.height); 

      [UIView commitAnimations]; 

      break; 

     default: 
      break; 
    } 
} 

- (void)zoomAction:(UITapGestureRecognizer *)sender { 
    switch (sender.view.tag) { 
     case 1: 
      [self.view bringSubviewToFront:_v1]; 
      [_v1 removeGestureRecognizer:[_v1.gestureRecognizers objectAtIndex:0]]; 

      [UIView beginAnimations:nil context:NULL]; 
      [UIView setAnimationDuration:1]; 
      [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

      _v1.transform = CGAffineTransformIdentity; 
      _v1.frame = CGRectMake(0., 0., _v1.frame.size.width, _v1.frame.size.height); 

      [UIView commitAnimations]; 

      break; 

     case 2: 
      [self.view bringSubviewToFront:_v2]; 
      [_v2 removeGestureRecognizer:[_v2.gestureRecognizers objectAtIndex:0]]; 

      [UIView beginAnimations:nil context:NULL]; 
      [UIView setAnimationDuration:1]; 
      [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

      _v2.transform = CGAffineTransformIdentity; 
      _v2.frame = CGRectMake(0., 0., _v2.frame.size.width, _v2.frame.size.height); 

      [UIView commitAnimations]; 
      break; 

     case 3: 
      [self.view bringSubviewToFront:_v3]; 
      [_v3 removeGestureRecognizer:[_v3.gestureRecognizers objectAtIndex:0]]; 

      [UIView beginAnimations:nil context:NULL]; 
      [UIView setAnimationDuration:1]; 
      [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

      _v3.transform = CGAffineTransformIdentity; 
      _v3.frame = CGRectMake(0., 0., _v3.frame.size.width, _v3.frame.size.height); 

      [UIView commitAnimations]; 
      break; 

     case 4: 
      [self.view bringSubviewToFront:_v4]; 
      [_v4 removeGestureRecognizer:[_v4.gestureRecognizers objectAtIndex:0]]; 

      [UIView beginAnimations:nil context:NULL]; 
      [UIView setAnimationDuration:1]; 
      [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

      _v4.transform = CGAffineTransformIdentity; 
      _v4.frame = CGRectMake(0., 0., _v4.frame.size.width, _v4.frame.size.height); 

      [UIView commitAnimations]; 
      break; 

     default: 
      break; 
    } 
} 

- (void)viewDidUnload { 
    [super viewDidUnload]; 

    [self setV1:nil]; 
    [self setV2:nil]; 
    [self setV3:nil]; 
    [self setV4:nil]; 
} 

@end 

我希望它可以帮助。

+0

我试过你的例子,但我有很多奇怪的事情.. – 2012-04-13 12:19:22

+0

考虑到已经在飞行中创建了一个例子,但是,什么? – WhiteTiger 2012-04-13 12:21:36

+0

我试过你的例子,但我有很多奇怪的事情.. 首先,所有的thumbmails是不一样的,我的看法:/ 我有一个ScrollView不能滚动时,视图是带到前面,哪些不是在良好的大小..我只有顶部我的桌子视图和其他2个视图都有一个透明部分。 我不明白,你有想法吗? 下面是我的观点截图: [链接](http://data.imagup.com/12/1148986155.2234png)。 我的代码如下。 非常感谢! – 2012-04-13 12:41:16