//

//  MenuHomeViewController.m

//  HFYS

//

//  Created by Showsoft_002 on 13-8-14.

//  Copyright (c) 2013年 Showsoft_002. All rights reserved.

//

#import "MenuHomeViewController.h"

#import "MainControlViewController.h"

#import "iCarousel.h"

#import "AssitentTimer.h"

#import "ContentPageViewController.h"

#import "ItemsSubViewIndex.h"

#import "UIEffectDesignerView.h"

#import "CalculatorViewController.h"

#import "JiSuanQiViewController.h"

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

#define NUMBER_OF_ITEMS (IS_IPAD? 19: 12)

#define NUMBER_OF_VISIBLE_ITEMS 5

#define ITEM_SPACING 77

#define INCLUDE_PLACEHOLDERS NO

typedefenum {

items_BrandHomeView = 0 ,

items_TraficHomeView,

items_ProjectHomeView ,

items_PropertyShowView,

items_CalulatorShowView,

}ItemsViewControllerNameEnum;

@interfaceMenuHomeViewController ()<iCarouselDataSource , iCarouselDelegate,AsstentTimerDelegate>{

UIImageView *backImageView;

int subViewIndex;

iCarousel *myIcarousel;

NSArray *contentArray;

JiSuanQiViewController *jisuanqiView;

ContentPageViewController *contentPageView;

CGRect remberFrame;

NSTimer *animationTimer;

}

-(void)calButtonAction:(UIButton *)sender;

@end

@implementation MenuHomeViewController

- (void)dealloc{

if( contentPageView ){

[contentPageView.viewremoveFromSuperview];

contentPageView = nil;

}

myIcarousel.delegate = nil;

myIcarousel.dataSource = nil;

[myIcarouselremoveFromSuperview];

myIcarousel = nil ;

contentArray = nil ;

[backImageViewremoveFromSuperview];

backImageView = nil ;

[selfstopMenuTimer];

}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

// Custom initialization

}

returnself;

}

- (void)viewDidLoad

{

[superviewDidLoad];

// Do any additional setup after loading the view.

backImageView = [[UIImageViewalloc]initWithFrame:CurrentDeviceBounds];

backImageView.userInteractionEnabled = YES ;

backImageView.tag = 1 ;

[self.viewaddSubview:backImageView];

UIEffectDesignerView* effectView = [UIEffectDesignerVieweffectWithFile:@"StartPage.ped"];

[backImageView addSubview:effectView];

contentArray = [NSArrayarrayWithObjects:

SSENCRYPTED_IMAGE(@"Item_pic1.png"),SSENCRYPTED_IMAGE(@"Item_pic2.png"),SSENCRYPTED_IMAGE(@"Item_pic3.png"),SSENCRYPTED_IMAGE(@"Item_pic4.png"),SSENCRYPTED_IMAGE(@"Item_pic5.png"),

nil];

//    myIcarousel = [[iCarousel alloc] initWithFrame:CGRectMake(0, 670/2 , 1024, 300)];//CGRectMake(0, 392/2-150, 790, 515)

//    myIcarousel.type = iCarouselTypeCylinder;

//    myIcarousel.delegate = self;

//    myIcarousel.dataSource = self;

//    //add carousel to view

//    [backImageView addSubview:myIcarousel];

}

- (void)didReceiveMemoryWarning

{

[superdidReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

- (void)enterAnimationWhenAppear{

float delayTimes = 0;

GYLWhiteMaskView *logo = [self addLogoWithFrame:CGRectMake((1024-216)/2, 126/2, 216, 185) inView:backImageView];

[selfgeneryallyAnimationWithView:logo animationType:GenerallyAnimationSliderFormTopduration:0.3delayTime:delayTimes finishedBlock:nil];

delayTimes += 0.3;

NSArray *array = [NSArray arrayWithObjects:

[NSValue valueWithCGPoint:CGPointMake(926/2, 672/2)],@"Item_pic3.png",

[NSValue valueWithCGPoint:CGPointMake(656/2, 730/2)],@"Item_pic2.png",

[NSValue valueWithCGPoint:CGPointMake(1224/2, 730/2)],@"Item_pic4.png",

[NSValue valueWithCGPoint:CGPointMake(406/2, 766/2)],@"Item_pic1.png",

[NSValue valueWithCGPoint:CGPointMake(1488/2, 766/2)],@"Item_pic5.png",

nil];

for( int i=0;i<5;i++ ){

NSString *string = [array objectAtIndex:2*i+1];

UIImage *locImage = SSENCRYPTED_IMAGE(string);

CGRect framess ;

framess.origin = [[array objectAtIndex:2*i] CGPointValue];

framess.size = locImage.size;

UIButton *button = [UIButtonbuttonWithType:UIButtonTypeCustom];

button.frame = framess;

button.tag = 100 + i ;

[button setBackgroundImage:locImage forState:UIControlStateNormal];

[button addTarget:selfaction:@selector(itemsButtonAction:) forControlEvents:UIControlEventTouchUpInside];

[backImageView addSubview:button];

[selfpopAnimationAndRoateWithView:button delayTime:delayTimes];

if( i%2 == 0 ) delayTimes += 0.6 ;

}

UIButton *backHomeButton = [UIButtonbuttonWithType:UIButtonTypeCustom];

backHomeButton.frame = CGRectMake((1024-146)/2, 1374/2 - 20, 146, 20+40);

[backHomeButton setImage:SSENCRYPTED_IMAGE(@"BackHomeButton.png") forState:UIControlStateNormal];

[backHomeButton addTarget:selfaction:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];

[backImageView addSubview: backHomeButton];

[selfgeneryallyAnimationWithView:backHomeButton animationType:GenerallyAnimationSliderFormBottomduration:0.3delayTime:delayTimes finishedBlock:nil];

UIButton *calButton = [UIButtonbuttonWithType:UIButtonTypeCustom];

calButton.frame = CGRectMake(1906/2 - 10, 32/2-10, 36+20, 36+20);

[calButton setImage:SSENCRYPTED_IMAGE(@"CalclutorBtn.png") forState:UIControlStateNormal];

[calButton addTarget:selfaction:@selector(calButtonAction:) forControlEvents:UIControlEventTouchUpInside];

[backImageView addSubview:calButton];

[selfgeneryallyAnimationWithView:calButton animationType:GenerallyAnimationSliderFormTopduration:0.3delayTime:delayTimes finishedBlock:nil];

[selfstartAssitentTimer];

[selfstartMenuTimer];

}

-(void)startMenuTimer{

//定时翻转列表

animationTimer = [NSTimerscheduledTimerWithTimeInterval:3target:selfselector:@selector(timeAction:) userInfo:nilrepeats:YES];

}

-(void)stopMenuTimer{

//释放Timer

if (animationTimer) {

[animationTimerinvalidate];

animationTimer = nil;

}

}

//定时器事件

-(void)timeAction:(id)sender

{

NSLog(@"time");

[selfstartItemAnimation:YES];

}

//播放列表动画

-(void)startItemAnimation:(BOOL)isLeft

{

int count=5;

if(!isLeft)

{

for (int i=0; i<count; i++) {

[UIViewanimateWithDuration:0.7delay:0.2*i options:UIViewAnimationOptionCurveEaseInOutanimations:^{

UIView *parentView = [backImageView viewWithTag:100+(count-1 -i)];

//设置动画效果

[UIViewsetAnimationTransition: UIViewAnimationTransitionFlipFromRightforView:parentView cache:NO];  //从上向下

}completion:nil];

}

}else

{

for (int i=0; i<count; i++) {

[UIViewanimateWithDuration:0.7delay:0.2*i options:UIViewAnimationOptionCurveEaseInOutanimations:^{

UIView *parentView = [backImageView viewWithTag:100+i];

//设置动画效果

[UIViewsetAnimationTransition: UIViewAnimationTransitionFlipFromLeftforView:parentView cache:NO];  //从上向下

}completion:nil];

}

}

}

- (void)popAnimationAndRoateWithView:(UIView *)animationView delayTime:(float)delayTime{

__weakMenuHomeViewController *weakSelf = self ;

[selfgeneryallyAnimationWithView:animationView animationType:GenerallyAnimationPopOutduration:0.3delayTime:delayTime finishedBlock:^{

[weakSelf roateAnimationWithView:animationView];

}];

}

- (void)roateAnimationWithView:(UIView *)animaitonView{

[UIViewanimateWithDuration:0.7delay:0options:UIViewAnimationOptionCurveEaseInOutanimations:^{

//设置动画效果

[UIViewsetAnimationTransition: UIViewAnimationTransitionFlipFromLeftforView:animaitonView cache:NO];  //从上向下

}completion:nil];

}

- (void)backButtonAction:(UIButton *)sender{

UIResponder *sponder = [selfcheckNextResponderIsKindOfViewController:[MainControlViewControllerclass]];

if( sponder ){

MainControlViewController *lfc = (MainControlViewController *)sponder ;

[lfc transViewToHomePageView];

}

}

- (void)playVideoAction:(UIButton *)sender{

UIResponder *sponder = [selfcheckNextResponderIsKindOfViewController:[MainControlViewControllerclass]];

if( sponder ){

MainControlViewController *lfc = (MainControlViewController *)sponder ;

[lfc transViewToVideoView];

}

}

- (void)calculatorButtonAction:(UIButton *)sender{

if( contentPageView ) return ;

remberFrame = sender.frame ;

contentPageView = [[ContentPageViewControlleralloc]init];

contentPageView.transIndex = PageSix_Title;

contentPageView.view.frame = CurrentDeviceBounds;

[self.viewaddSubview:contentPageView.view];

[selffallInTransitionToView:contentPageView.viewwith:backImageViewanimationTime:0.5transContent:nilcompletion:^{

[contentPageViewenterAnimationWhenAppear];

}];

}

- (void)releaseAddSubView{

if(jisuanqiView)

{

[selfgeneryallyAnimationWithView:jisuanqiView.viewanimationType:GenerallyAnimationFadeOutduration:.5delayTime:0finishedBlock:^{

[jisuanqiView.viewremoveFromSuperview];

jisuanqiView=nil;

}];

}

if( !contentPageView ) return ;

backImageView.alpha = 1 ;

backImageView.transform = CGAffineTransformScale(CGAffineTransformMakeRotation(0.0) , 1.f , 1.f);

[selfbackTransitionWithView:contentPageView.viewto:backImageViewtransFrame:remberFrameanimationTime:0.5transContent:nilcompletion:^{

[contentPageView.viewremoveFromSuperview];

contentPageView = nil;

[selfstartAssitentTimer];

[selfstartMenuTimer];

}];

}

- (void)startAssitentTimer{

//    [[self.view viewWithTag:123456] removeFromSuperview];

//

//    AssitentTimer *locView = [[AssitentTimer alloc]initWithFrame:CGRectMake(0, 0, 10, 10)];

//    locView.userInteractionEnabled = NO ;

//    locView.tag = 123456;

//    locView.myDelegate = self ;

//    [self.view insertSubview:locView atIndex:0];

//

//    [locView startTimerWithTime:3 isLoop:YES];

}

- (void)assitentTimerEndWithCurrentView:(UIView *)currentView{

//    int nums = myIcarousel.currentItemIndex;

//    nums ++ ;

//    if( nums >= [contentArray count]*2 ){

//        nums = 0 ;

//    }

//

//    [myIcarousel scrollToItemAtIndex:nums animated:YES];

}

- (void)stopAssitentTimer{

//    [[self.view viewWithTag:123456] removeFromSuperview];

}

#pragma mark -

#pragma mark iCarousel methods

- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel

{

return [contentArraycount]*2;

}

- (NSUInteger)numberOfVisibleItemsInCarousel:(iCarousel *)carousel

{

//limit the number of items views loaded concurrently (for performance reasons)

returnNUMBER_OF_VISIBLE_ITEMS;

}

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view

{

//create new view if no view is available for recycling

if (view == nil)

{

view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ITEM_SPACING, myIcarousel.bounds.size.height)];

view.clipsToBounds = NO ;

UIImageView *downImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 77, 200)];

downImageView.tag = 10 ;

[view addSubview:downImageView];

}

UIImageView *downImageView = (UIImageView *)[view viewWithTag:10];

//    NSString *string = [downImageArray objectAtIndex:index % 4];

downImageView.image = [contentArray objectAtIndex:index%5 ];

return view;

}

- (NSUInteger)numberOfPlaceholdersInCarousel:(iCarousel *)carousel

{

//note: placeholder views are only displayed if wrapping is disabled

returnINCLUDE_PLACEHOLDERS? 2: 0;

}

- (CGFloat)carouselItemWidth:(iCarousel *)carousel

{

//slightly wider than item view

returnITEM_SPACING;

}

- (BOOL)carouselShouldWrap:(iCarousel *)carousel

{

//wrap all carousels

returnYES;

}

- (CGFloat)carousel:(iCarousel *)carousel itemAlphaForOffset:(CGFloat)offset

{

//set opacity based on distance from camera

return 1.0f - fminf(fmaxf(offset, 0.0f), 1.0f);

}

- (CATransform3D)carousel:(iCarousel *)_carousel itemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform

{

//implement 'flip3D' style carousel

transform = CATransform3DRotate(transform, M_PI / 8.0f, 0.0f, 1.0f, 0.0f);

return CATransform3DTranslate(transform, 0.0f, 0.0f, offset * myIcarousel.itemWidth);

}

- (CGFloat)carousel:(iCarousel *)carousel valueForTransformOption:(iCarouselTranformOption)option withDefault:(CGFloat)value

{

switch (option)

{

caseiCarouselTranformOptionArc:

{

return 2 * M_PI * 0.1;

}

caseiCarouselTranformOptionRadius:

{

return value * 1.8;

}

caseiCarouselTranformOptionTilt:

{

return 0.5;

}

caseiCarouselTranformOptionSpacing:

{

return 1;

}

default:

{

return value;

}

}

}

- (void)carouselWillBeginDragging:(iCarousel *)carousel{

[selfstopAssitentTimer];

}

- (void)carouselDidEndDragging:(iCarousel *)carousel willDecelerate:(BOOL)decelerate{

[selfstartAssitentTimer];

}

- (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index{

if( contentPageView ) return ;

[selfstopAssitentTimer];

NSArray *array = [NSArray arrayWithObjects:

[NSNumber numberWithInt:PageOne_Title],

[NSNumber numberWithInt:PageTwo_Title],

[NSNumber numberWithInt:PageThree_Title],

[NSNumber numberWithInt:PageFour_Title],

[NSNumber numberWithInt:PageFive_Title],

nil];

int nums = index % 5 ;

UIView *locView = [myIcarousel itemViewAtIndex:index];

UIImageView *imageView = (UIImageView *)[locView viewWithTag:10];

remberFrame = [locView convertRect:imageView.frame toView:backImageView];

NSLog(@"remberFrame is %@" , NSStringFromCGRect(remberFrame));

contentPageView = [[ContentPageViewControlleralloc]init];

contentPageView.transIndex = [[array objectAtIndex:nums] integerValue];

contentPageView.view.frame = CurrentDeviceBounds;

[self.viewaddSubview:contentPageView.view];

[selffallInTransitionToView:contentPageView.viewwith:backImageViewanimationTime:0.5transContent:nilcompletion:^{

[contentPageViewenterAnimationWhenAppear];

}];

}

- (void)itemsButtonAction:(UIButton *)sender{

int index = sender.tag % 100 ;

if( contentPageView ) return ;

[selfstopAssitentTimer];

NSArray *array = [NSArray arrayWithObjects:

[NSNumber numberWithInt:PageThree_Title],

[NSNumber numberWithInt:PageTwo_Title],

[NSNumber numberWithInt:PageFour_Title],

[NSNumber numberWithInt:PageOne_Title],

[NSNumber numberWithInt:PageFive_Title],

nil];

int nums = index % 5 ;

remberFrame = sender.frame;

NSLog(@"remberFrame is %@" , NSStringFromCGRect(remberFrame));

contentPageView = [[ContentPageViewControlleralloc]init];

contentPageView.transIndex = [[array objectAtIndex:nums] integerValue];

contentPageView.view.frame = CurrentDeviceBounds;

[self.viewaddSubview:contentPageView.view];

[selffallInTransitionToView:contentPageView.viewwith:backImageViewanimationTime:0.5transContent:nilcompletion:^{

[contentPageViewenterAnimationWhenAppear];

}];

[selfstopMenuTimer];

}

//计算器

-(void)calButtonAction:(UIButton *)sender

{

if( contentPageView ) return ;

remberFrame = sender.frame;

contentPageView = [[ContentPageViewControlleralloc]init];

contentPageView.transIndex = PageSix_Title;

contentPageView.view.frame = CurrentDeviceBounds;

[self.viewaddSubview:contentPageView.view];

[selffallInTransitionToView:contentPageView.viewwith:backImageViewanimationTime:0.5transContent:nilcompletion:^{

[contentPageViewenterAnimationWhenAppear];

}];

//    jisuanqiView=[[JiSuanQiViewController alloc]init];

//    jisuanqiView.view.frame=CurrentDeviceBounds;

//    [self.view addSubview:jisuanqiView.view];

//

//    [jisuanqiView enterAnimationWhenAppear];

}

@end

项目用到的icarouls类和UIEffectDesignerView类,菜单技巧,构思(金方圆)的更多相关文章

  1. .NET平台开源项目速览(18)C#平台JSON实体类生成器JSON C# Class Generator

    去年,我在一篇文章用原始方法解析复杂字符串,json一定要用JsonMapper么?中介绍了简单的JSON解析的问题,那种方法在当时的环境是非常方便的,因为不需要生成实体类,结构很容易解析.但随着业务 ...

  2. AspNet Core Web 应用程序的启动(有关 Program.cs类/ Startup.cs类 ) 当项目中干掉 Startup.cs 类如何设置启动 配置等等

    .有关怎么创建Core MVC/API 这里就不说了,前段时间的博客有说过: 1.  项目生成后会有如图所示两个类 Program类Startup类 2. Startup类  初始内容 public ...

  3. eclipse怎么对项目重命名,eclipse怎么重命名类

    eclipse怎么对项目重命名,eclipse怎么重命名类

  4. Django商城项目笔记No.3用户部分-用户模型类

    Django商城项目笔记No.3用户部分-用户模型类 Django提供了认证系统,文档资料https://yiyibooks.cn/xx/Django_1.11.6/topics/auth/index ...

  5. C++第11周(春)项目3 - 点类派生直线类

    课程首页在:http://blog.csdn.net/sxhelijian/article/details/11890759.内有完整教学方案及资源链接 [项目3 - 点类派生直线类]定义点类Poin ...

  6. 扩展银行项目,添加一个(客户类)Customer类。Customer类将包含一个Account对象。

    练习目标-使用引用类型的成员变量:在本练习中,将扩展银行项目,添加一个(客户类)Customer类.Customer类将包含一个Account对象. 任务 在banking包下的创建Customer类 ...

  7. 编写Java程序,使用ThreadLocal类,项目中创建账户类 Account,类中包括账户名称name、 ThreadLocal 类的引用变量amount,表示存款

    查看本章节 查看作业目录 需求说明: 某用户共有两张银行卡,账户名称相同,但卡号和余额不同.模拟用户使用这两张银行卡进行消费的过程,并打印出消费明细 实现思路: 项目中创建账户类 Account,类中 ...

  8. SSM项目web.xml等配置文件中如何查找类的全路径名?

    如题, web.xml,applicationContext.xml 等配置文件中,有时不会出现自动提示类的名字,这时如何查找类的全路径名,如下图所示: 1.鼠标右键单击菜单栏Navigate选项,选 ...

  9. JavaWeb网上图书商城完整项目--day03-1.图书模块功能介绍及相关类创建

    1 前两天我们学习了user用户模块和图书的分类模块,接下来我们学习图书模块 图书模块的功能主要是下面的功能: 2 接下来我们创建对应的包 我们来看看对应的数据库表t_book CREATE TABL ...

随机推荐

  1. Sql Server xml 类型字段的增删改查

    1.定义表结构 在MSSM中新建数据库表CommunicateItem,定义其中一个字段ItemContentXml 为xml类型 2.编辑表数据,新增一行,发现xml类型不能通过设计器录入数据. 需 ...

  2. php基础_函数和类

    ①函数 1.函数名不区分大小写,变量名区分大小写. 2.require()和include() 区别:函数加载失败后,require给出一个致命错误,include只是一个警告. ②类 1.构造方法 ...

  3. css3各个属性的兼容

    1.transition:IE10. Firefox.Opera.Chrome支持: Safari支持替代的-webkit-transition属性: 2.animation: IE10.FIrefo ...

  4. Linux开源系统对比Windows闭源系统的优势解析

    当我们听到linux的时候是不是觉得高大上的感觉呢?在我刚上大学的时候,听着学长们给我讲他们的大学的学习经历,先学习C语言.单片机.然后做一些项目,现在正学习linux操作系统,当我听到linux操作 ...

  5. POJ 2229 Sumsets

    Sumsets Time Limit: 2000MS   Memory Limit: 200000K Total Submissions: 11892   Accepted: 4782 Descrip ...

  6. Ubuntu上安装MySql过程,以及遇到的一些问题

    今天在Ubuntu服务器上安装MySql的时候遇到了一些问题,记录下来,以防以后忘记. 安装环境:Ubuntu14.04 安装命令: //安装Mysal服务端//会提示输入root密码 sudo ap ...

  7. 003-Tuple、Array、Map与文件操作入门实战

    003-Tuple.Array.Map与文件操作入门实战 Tuple 各个元素可以类型不同 注意索引的方式 下标从1开始 灵活 Array 注意for循环的until用法 数组的索引方式 上面的for ...

  8. 使用CSS3动画模拟实现小球自由落体效果

    使用纯CSS代码模拟实现小球自由落体效果: html代码如下: <div id="ballDiv"> <div id="ball">&l ...

  9. GoldenGate Studio 12.2.1.1发布

    OGG studio是一款图形化OGG配置部署产品,其主要特性:1. 逻辑层面设计OGG,不需要了解OGG细节:2. 最值实践加快常用场景的配置:3. 使用拖拉映射,自动匹配源和目标对象:4. 一键部 ...

  10. js的异常捕获

    try{ ...some code... }catch(e){ ...some code... //处理错误 throw(e.name); //抛出异常 }finally{<BR> // ...