赞
踩
高仿网易 4.0 新 UI 框架的 Demo
功能描述:
1. 右视图滑动导航菜单的字体大小和颜色,随scrollView滑动的变化而变化的效果.
2. 新的抽屉效果,修改于SliderViewController,仿网易新闻的界面.
3. 各种侧滑 跳转
效果图:
创建三个类
QHViewController, LeftViewController,MainViewController
Appdelegate的设置如下
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- // Override point for customization after application launch.
- self.window.backgroundColor = [UIColor whiteColor];
- [self.window makeKeyAndVisible];
- LeftViewController * LeftVC=[[LeftViewController alloc]init];
- [LeftVC.view setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
- [QHViewController shareSlideController].LeftVC=LeftVC;
-
- MainViewController * MainVC=[[MainViewController alloc]init];
- [MainVC.view setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
- [QHViewController shareSlideController].MainVC=MainVC;
-
- UINavigationController * nvc=[[UINavigationController alloc]initWithRootViewController:[QHViewController shareSlideController]];
- self.window.rootViewController=nvc;
-
-
- return YES;
- }
QHViewController中实现主视图与左视图的滑动显示的代码
- //
- // QHViewController.m
- // 侧滑--仿酷狗
- //
- // Created by mac1 on 14-9-19.
- // Copyright (c) 2014年 mac1. All rights reserved.
- //
-
- #import "QHViewController.h"
-
- @interface QHViewController ()
- {
- UIView * _mainContentView;
- UIView * _leftSideView;
- UISwipeGestureRecognizer * swipeGesture;
- }
- @end
-
- @implementation QHViewController
-
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- +(QHViewController *)shareSlideController
- {
- static QHViewController * shareVC;
- static dispatch_once_t oneToke;
- dispatch_once(&oneToke ,^{
- shareVC=[[self alloc]init];
- });
- return shareVC;
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- /* { hide status bar } */
- //隐藏导航栏
- [[self navigationController] setNavigationBarHidden:YES];
-
- [super viewWillAppear:animated];
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
-
- self.navigationController.navigationBarHidden=YES;
-
- //创建视图
- [self initSubviews];
-
- }
-
- -(void)initSubviews
- {
-
- //创建主视图
- _mainContentView = [[UIView alloc] initWithFrame:self.view.bounds];
-
- [self.view addSubview:_mainContentView];
- [_mainContentView addSubview:_MainVC.view];
- // //创建左视图
- _leftSideView=[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width*0.5, 0, self.view.frame.size.width, self.view.frame.size.height)];
- [_leftSideView addSubview:_LeftVC.view];
- [self.view addSubview:_leftSideView];
-
- }
- -(void)showLeftView
- {
- [UIView beginAnimations:nil context:nil];
- [UIView setAnimationDuration:.5];
- _leftSideView.frame=CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
- [UIView commitAnimations];
- }
- -(void)closeLeftView
- {
- [UIView beginAnimations:nil context:nil];
- [UIView setAnimationDuration:.5];
-
- _leftSideView.frame=CGRectMake(self.view.frame.size.width*0.5, 0, self.view.frame.size.width, self.view.frame.size.height);
- [UIView commitAnimations];
- }
-
- @end
LeftViewController的设置
属性设置
- //导航栏视图
- UIImageView * _navView;
- //标签栏视图
- UIView * _topNaviV;
- //滑动视图
- UIScrollView * _scrollView;
- //下拉视图
- UIView * _selectTabV;
- //标签栏滑动子视图
- UIScrollView * _navScrollV;
- //视图的轻扫手势
- UISwipeGestureRecognizer * swipeGesture1;
- - (void)viewDidLoad
- {
- [super viewDidLoad];
-
- //给视图添加轻扫手势,轻扫显示主界面
- self.view.backgroundColor=[UIColor cyanColor];
- swipeGesture1=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeGesture1Action)];
- swipeGesture1.direction=UISwipeGestureRecognizerDirectionRight;
- [self.view addGestureRecognizer:swipeGesture1];
- //创建导航栏
- _navView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height*0.2)];
- [_navView setBackgroundColor:[UIColor redColor]];
- [self.view addSubview:_navView];
- //导航栏标题
- UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake((_navView.frame.size.width - 200)/2, (_navView.frame.size.height - 40)/2, 200, 40)];
- [titleLabel setText:@"新闻列表"];
- [titleLabel setTextAlignment:NSTextAlignmentCenter];
- [titleLabel setTextColor:[UIColor whiteColor]];
- [titleLabel setFont:[UIFont boldSystemFontOfSize:22]];
- [titleLabel setBackgroundColor:[UIColor clearColor]];
- [_navView addSubview:titleLabel];
- //导航栏button,点击可显示主界面
- UIButton * button=[[UIButton alloc]initWithFrame:CGRectMake(10, 40, 30, 30)];
- [button setTitle:@"+" forState:UIControlStateNormal];
- [button setBackgroundColor:[UIColor blueColor]];
- button.selected=NO;
- [button addTarget:self action:@selector(baButton:) forControlEvents:UIControlEventTouchUpInside];
- _navView.userInteractionEnabled=YES;
- [_navView addSubview:button];
-
- //创建标签栏_navView.frame.origin.y是_navView的起始坐标,创建标签视图,可滑动
- _topNaviV = [[UIView alloc] initWithFrame:CGRectMake(0, _navView.frame.size.height + _navView.frame.origin.y, self.view.frame.size.width, 36)];
- _topNaviV.backgroundColor = [UIColor orangeColor];
- [self.view addSubview:_topNaviV];
- //创建滑动视图
- _scrollView =[[UIScrollView alloc]initWithFrame:CGRectMake(0,_topNaviV.frame.origin.y+_topNaviV.frame.size.height, self.view.frame.size.width,self.view.frame.size.height- (_topNaviV.frame.origin.y+_topNaviV.frame.size.height))];
- [_scrollView setPagingEnabled:YES];
- _scrollView.showsHorizontalScrollIndicator=NO;
- [self.view insertSubview:_scrollView belowSubview:
- _navView];
- _scrollView.delegate=self;
- //创建一个平移手势,添加到滑动视图上 可以调用handelPan:方法
- [_scrollView.panGestureRecognizer addTarget:self action:@selector(scrollHandlePan:)];
- [_scrollView setContentSize:CGSizeMake(self.view.frame.size.width * 10,_scrollView.frame.size.height)];
- _scrollView.tag=101;
- //创建下拉视图,设置为隐藏
- _selectTabV = [[UIView alloc] initWithFrame:CGRectMake(0, _scrollView.frame.origin.y - _scrollView.frame.size.height, _scrollView.frame.size.width, _scrollView.frame.size.height)];
- [_selectTabV setBackgroundColor:[UIColor orangeColor]];
- [_selectTabV setHidden:YES];
- [self.view insertSubview:_selectTabV belowSubview:_navView];
- //调用标签视图布局
- [self createTwo];
-
- }
- -(void)baButton:(UIButton*)button
- {
- if (button.selected==YES) {
-
- [[QHViewController shareSlideController]closeLeftView];
- }
- else if(button.selected==NO)
- {
- [[QHViewController shareSlideController]showLeftView];
- }
- button.selected=!button.selected;
- }
- //标签视图的布局
- -(void)createTwo
- {
- float btnW = 30;
- //创建下拉视图的button
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- [btn setFrame:CGRectMake(_topNaviV.frame.size.width - btnW, 0, btnW, 36)];
- [btn setBackgroundColor:[UIColor grayColor]];
- [btn setTitle:@"+" forState:UIControlStateNormal];
- //button添加在滑动标签视图上
- [_topNaviV addSubview:btn];
- [btn addTarget:self action:@selector(showSelectView:) forControlEvents:UIControlEventTouchUpInside];
-
- NSArray *arT = @[@"推荐", @"彩票", @"热点", @"社会", @"娱乐", @"财经", @"军事", @"科技", @"国际", @"体育"];
- //创建滑动标签视图
- _navScrollV = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width - btnW, 36)];
- [_navScrollV setShowsHorizontalScrollIndicator:NO];
- _navScrollV.delegate=self;
- _navScrollV.tag=100;
- for (int i = 0; i < [arT count]; i++)
- {
- //创建标签试图上的每一个button
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- [btn setFrame:CGRectMake(60 * i, 0, 60,36)];
- [btn setTitle:[arT objectAtIndex:i] forState:UIControlStateNormal];
- [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- btn.tag = i + 1;
- if(i==0)
- {
- //第一个button颜色字体的设置
- [self changeColorForButton:btn red:1];
- btn.titleLabel.font = [UIFont systemFontOfSize:18.f];
- }else
- {
- //其它button的设置
- btn.titleLabel.font = [UIFont systemFontOfSize:13.f];
- //[self changeColorForButton:btn red:0];
- }
- //添加按钮事件
- [btn addTarget:self action:@selector(actionbtn:) forControlEvents:UIControlEventTouchUpInside];
- [_navScrollV addSubview:btn];
- }
- //设置标签视图的内容视图大小
- [_navScrollV setContentSize:CGSizeMake(60 * [arT count], 36)];
- [_topNaviV addSubview:_navScrollV];
- //调用滑动视图布局
- [self addView2Page:_scrollView count:[arT count] frame:CGRectZero];
- }
- //滑动视图布局
- - (void)addView2Page:(UIScrollView *)scrollV count:(NSUInteger)pageCount frame:(CGRect)frame
- {
- for (int i = 0; i < pageCount; i++)
- {
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(scrollV.frame.size.width * i, 0, scrollV.frame.size.width, scrollV.frame.size.height)];
- view.tag = i + 1;
- view.userInteractionEnabled = YES;
- //给每个视图添加点击事件
- UITapGestureRecognizer *singleTapRecognizer = [[UITapGestureRecognizer alloc] init];
- singleTapRecognizer.numberOfTapsRequired = 1;
- [singleTapRecognizer addTarget:self action:@selector(pust2View:)];
- [view addGestureRecognizer:singleTapRecognizer];
- //调用滑动视图子视图设置方法
- [self initPageView:view];
-
- [scrollV addSubview:view];
- }
- //设置scrollV的宽度为10个屏幕的宽度
- [scrollV setContentSize:CGSizeMake(scrollV.frame.size.width * pageCount, scrollV.frame.size.height)];
- }
- -(void)pust2View:(UITapGestureRecognizer *)singleTapRecognizer
- {
-
- }
- //滑动视图子视图设置方法
- - (void)initPageView:(UIView *)view
- {
- int width = (view.frame.size.width - 20)/3;
- float x = 5;
- float y = 4;
- UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 10, self.view.frame.size.width, self.view.frame.size.height - 64)];
- int sumJ = (int)(1+arc4random()%4);
- int sumI = (int)(1+arc4random()%3);
- for (int j = 1; j <= sumJ; j++)
- {
- for (int i = 1; i <= 3; i++)
- {
- if (j == sumJ && i > sumI)
- {
- break;
- }
- float w = x * i + width * (i - 1);
- float h = y * j + width * (j - 1);
- UILabel *l = [[UILabel alloc] initWithFrame:CGRectMake(w, h, width, width)];
- [l setBackgroundColor:[QHCommonUtil getRandomColor]];
- [v addSubview:l];
- }
- }
-
- [view addSubview:v];
- }
- //显示下拉视图的方法,有动画
- - (void)showSelectView:(UIButton *)btn
- {
-
- if ([_selectTabV isHidden] == YES)
- {
- [_selectTabV setHidden:NO];
- [UIView animateWithDuration:0.6 animations:^
- {
- [_selectTabV setFrame:CGRectMake(0, _scrollView.frame.origin.y, _scrollView.frame.size.width, _scrollView.frame.size.height)];
- } completion:^(BOOL finished)
- {
- }];
- }else
- {
- [UIView animateWithDuration:0.6 animations:^
- {
- [_selectTabV setFrame:CGRectMake(0, _scrollView.frame.origin.y - _scrollView.frame.size.height, _scrollView.frame.size.width, _scrollView.frame.size.height)];
- } completion:^(BOOL finished)
- {
- [_selectTabV setHidden:YES];
- }];
- }
-
- }
- -(void)swipeGesture1Action
- {
- [[QHViewController shareSlideController]closeLeftView];
- }
- -(void)scrollHandlePan:(UIPanGestureRecognizer*) panParam
- {
- BOOL isPaning = NO;
- //contentOffset 是scrollview当前显示区域顶点相对于frame顶点的偏移量,比如上个例子你拉到最下面,contentoffset就是(0 ,480),也就是y偏移了480
- //假如x偏移量为0
- if(_scrollView.contentOffset.x < 0)
- {
- isPaning = YES;
- // isLeftDragging = YES;
- // [self showMask];
- }
- //假如偏移量大于从第一个页面到最后一个页面的长度,
- else if(_scrollView.contentOffset.x > (_scrollView.contentSize.width - _scrollView.frame.size.width))
- {
- isPaning = YES;
- // isRightDragging = YES;
- // [self showMask];
- }
- //如果偏移量在范围内,要执行偏移
- if(isPaning==NO)
- {
- //[[QHViewController sharedSliderController] moveViewWithGesture:panParam];
- }
- }
- //标签是图按钮的点击方法,点击button,所对应的滑动视图也会滑动到相应的地方
- - (void)actionbtn:(UIButton *)btn
- {
- //如果上一次是点击button,则把上个button的字体与颜色恢复
- UIButton * button2=(UIButton *)[_navScrollV viewWithTag:currentTag];
- [button2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- button2.titleLabel.font = [UIFont systemFontOfSize:13.f];
- //如果上一次是滑动slidView视图,则把上个button的字体与颜色恢复
- UIButton * button3=(UIButton *)[_navScrollV viewWithTag:currentIndex];
- [button3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- button3.titleLabel.font = [UIFont systemFontOfSize:13.f];
-
- [UIView beginAnimations:nil context:nil];
- [UIView setAnimationDuration:.5];
- //点击button时主页面滑动,主页的x坐标改变
- //_scrollView的滑动
- [_scrollView scrollRectToVisible:CGRectMake(_scrollView.frame.size.width * (btn.tag - 1), _scrollView.frame.origin.y, _scrollView.frame.size.width, _scrollView.frame.size.height) animated:YES];
-
- //随着tag值增加,xx增大,标签视图的x坐标改变
- float xx = _scrollView.frame.size.width * (btn.tag - 1) * (60 / self.view.frame.size.width) ;
- //标签视图滑动
- [_navScrollV scrollRectToVisible:CGRectMake(xx, 0, _navScrollV.frame.size.width, _navScrollV.frame.size.height) animated:YES];
- [btn setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
- btn.titleLabel.font = [UIFont systemFontOfSize:18.f];
- currentTag=btn.tag;
- [UIView commitAnimations];
- }
-
- - (void)changeColorForButton:(UIButton *)btn red:(float)nRedPercent
- {
- //float value = [QHCommonUtil lerp:nRedPercent min:0 max:212];
- [btn setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
- }
- //- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
- //{
- // _startPointX = scrollView.contentOffset.x;
- // //NSLog(@"___________________%f",_startPointX);
- //
- //}
- //滑动视图将要结束拖拽时调用
- -(void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
- {
- if(scrollView.tag==101)
- {
- //index是滑动视图滑动到第几个页面
- int index = targetContentOffset->x /320;
-
- UIButton * button2=(UIButton *)[_navScrollV viewWithTag:currentIndex];
- [button2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- button2.titleLabel.font = [UIFont systemFontOfSize:13.f];
-
- UIButton * button3=(UIButton *)[_navScrollV viewWithTag:currentTag];
- [button3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- button3.titleLabel.font = [UIFont systemFontOfSize:13.f];
-
- //NSLog(@"**************%d",index);
- //标签视图的x坐标
- float xx = _scrollView.frame.size.width * (index) * (60 / self.view.frame.size.width) ;
- //标签视图滑动
- [_navScrollV scrollRectToVisible:CGRectMake(xx, 0, _navScrollV.frame.size.width, _navScrollV.frame.size.height) animated:YES];
-
- UIButton * button1=(UIButton *)[_navScrollV viewWithTag:index+1];
- [button1 setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
- button1.titleLabel.font = [UIFont systemFontOfSize:18.f];
-
- currentIndex=index+1;
-
- }
-
- }
MainViewController的设置
- //
- // MainViewController.m
- // 侧滑--仿酷狗
- //
- // Created by mac1 on 14-9-19.
- // Copyright (c) 2014年 mac1. All rights reserved.
- //
-
- #import "MainViewController.h"
-
- @interface MainViewController ()
- {
- NSArray *_arData;
- }
- @end
-
- @implementation MainViewController
-
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"b"] ]];
- _arData = @[@"新闻", @"订阅", @"图片", @"视频", @"跟帖", @"电台"];
- float h =self.view.frame.size.height * 0.7/[_arData count];
-
- UIView * listV=[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width*0.1, h, self.view.frame.size.width-self.view.frame.size.width*0.3, h*[_arData count])];
- for (int i=0; i<6; i++) {
- UIButton * button=[[UIButton alloc]initWithFrame:CGRectMake(0, i*h,listV.frame.size.width, h)];
- UILabel * label=[[UILabel alloc]initWithFrame:CGRectMake(0,0,button.frame.size.width, h)];
-
- [label setFont:[UIFont systemFontOfSize:20]];
- [label setTextColor:[UIColor whiteColor]];
- [label setBackgroundColor:[UIColor clearColor]];
- [label setText:_arData[i]];
- [button addSubview:label];
- button.tag=200+i;
- [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
- [listV addSubview:button];
- [self.view addSubview:listV];
-
-
- }
- UISwipeGestureRecognizer * swipeGesture=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipAction)];
- swipeGesture.direction=UISwipeGestureRecognizerDirectionLeft;
- [listV addGestureRecognizer:swipeGesture];
- // UITapGestureRecognizer *tapGestureRec = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(swipAction)];
- // [listV addGestureRecognizer:tapGestureRec];
-
-
- }
- -(void)buttonAction:(UIButton*)button
- {
- if (button.tag==1) {
- NSLog(@"订阅");
- }
- // switch (button.tag) {
- // case 1:
- // NSLog(@"订阅");
- //
- // break;
- // case 2:
- // NSLog(@"图片");
- // break;
- // default:
- // break;
- // }
- }
- -(void)swipAction
- {
- [[QHViewController shareSlideController]showLeftView];
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
-
- @end
QQ空间侧滑
这里有四个主要的类:MainViewController,LeftViewController,RightViewController,WWSideslipViewController
init方法,把LeftView,MainView,RightView三个视图控制器传入,把左右视图设为隐藏,给主视图设置滑动,单击手势
- -(instancetype)initWithLeftView:(UIViewController *)LeftView
- andMainView:(UIViewController *)MainView
- andRightView:(UIViewController *)RighView
- andBackgroundImage:(UIImage *)image;
- {
- if(self){
- speedf = 0.5;
-
- leftControl = LeftView;
- mainControl = MainView;
- righControl = RighView;
-
- UIImageView * imgview = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];
- [imgview setImage:image];
- [self.view addSubview:imgview];
-
- //滑动手势
- UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan:)];
- [mainControl.view addGestureRecognizer:pan];
-
-
- //单击手势
- sideslipTapGes= [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handeTap:)];
- [sideslipTapGes setNumberOfTapsRequired:1];
-
- [mainControl.view addGestureRecognizer:sideslipTapGes];
-
- leftControl.view.hidden = YES;
- righControl.view.hidden = YES;
-
- [self.view addSubview:leftControl.view];
- [self.view addSubview:righControl.view];
-
- [self.view addSubview:mainControl.view];
-
- }
- return self;
- }
- //滑动手势
- - (void) handlePan: (UIPanGestureRecognizer *)rec{
- //得到坐标点
- CGPoint point = [rec translationInView:self.view];
-
- NSLog(@"____________________%@",NSStringFromCGPoint(point));
-
- scalef = (point.x*speedf+scalef);
- NSLog(@"scalef%f",scalef);
- //根据主视图位置判断是左滑还是右边滑动
- if (rec.view.frame.origin.x>=0){
- rec.view.center = CGPointMake(rec.view.center.x + point.x*speedf,rec.view.center.y);
- //设置缩放
- rec.view.transform = CGAffineTransformScale(CGAffineTransformIdentity,1-scalef/1000,1-scalef/1000);
- [rec setTranslation:CGPointMake(0, 0) inView:self.view];
- //设置左视图不隐藏,右视图隐藏
- righControl.view.hidden = YES;
- leftControl.view.hidden = NO;
-
- }
- else
- {
- rec.view.center = CGPointMake(rec.view.center.x + point.x*speedf,rec.view.center.y);
- rec.view.transform = CGAffineTransformScale(CGAffineTransformIdentity,1+scalef/1000,1+scalef/1000);
- [rec setTranslation:CGPointMake(0, 0) inView:self.view];
-
-
- righControl.view.hidden = NO;
- leftControl.view.hidden = YES;
- }
-
-
-
- //手势结束后修正位置
- if (rec.state == UIGestureRecognizerStateEnded) {
- if (scalef>140*speedf){
- [self showLeftView];
- }
- else if (scalef<-140*speedf) {
- [self showRighView]; }
- else
- {
- [self showMainView];
- scalef = 0;
- }
- }
-
- }
- #pragma mark - 单击手势
- -(void)handeTap:(UITapGestureRecognizer *)tap{
-
- if (tap.state == UIGestureRecognizerStateEnded) {
- [UIView beginAnimations:nil context:nil];
- tap.view.transform = CGAffineTransformScale(CGAffineTransformIdentity,1.0,1.0);
- tap.view.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
- [UIView commitAnimations];
- scalef = 0;
-
- }
-
- }
- #pragma mark - 修改视图位置
- //恢复位置
- -(void)showMainView{
- [UIView beginAnimations:nil context:nil];
- mainControl.view.transform = CGAffineTransformScale(CGAffineTransformIdentity,1.0,1.0);
- mainControl.view.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
- [UIView commitAnimations];
- }
-
- //显示左视图
- -(void)showLeftView{
- [UIView beginAnimations:nil context:nil];
- mainControl.view.transform = CGAffineTransformScale(CGAffineTransformIdentity,0.8,0.8);
- mainControl.view.center = CGPointMake(340,[UIScreen mainScreen].bounds.size.height/2);
- [UIView commitAnimations];
-
- }
-
- //显示右视图
- -(void)showRighView{
- [UIView beginAnimations:nil context:nil];
- mainControl.view.transform = CGAffineTransformScale(CGAffineTransformIdentity,0.8,0.8);
- mainControl.view.center = CGPointMake(-60,[UIScreen mainScreen].bounds.size.height/2);
- [UIView commitAnimations];
- }
-
- #warning 为了界面美观,所以隐藏了状态栏。如果需要显示则去掉此代码
- - (BOOL)prefersStatusBarHidden
- {
- return YES; //返回NO表示要显示,返回YES将hiden
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。