//

//  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. 总结4点对学习Linux有帮助的建议(纯干货)

    学习需要足够的毅力和耐心 有些人把Linux运维看作一项冗长而枯燥的工作:有些人把linux运维看作一项得力的工具.如果是前者建议还是改变一下认识,不然不建议入门这行.毕竟linux运维工作是对人的毅 ...

  2. Python学习07——字典(2)

    笨办法学Python第40节,上次用的第三版的书,这次是第四版的书. 这一节的代码如下: cities = {'CA':'San Francisco', 'MI':'Detroit', 'FL':'J ...

  3. VisualSVN-5.1.4补丁原创发布

    VisualSVN-5.1.4补丁原创发布 VisualSVN-5.1.4Patch.rar  VisualSVN-5.1.4官方安装包.rar

  4. Asp.net MVC与Javascript

    特性验证 首先:在web.config文件中<appSettings>节点内添加<add key="ClientValidationEnabled" value= ...

  5. C# Lamada表达式

    Lambda表达式 "Lambda表达式"是一个匿名函数,是一种高效的类似于函数式编程的表达式,Lambda简化了开发中需要编写的代码量.它可以包含表达式和语句,并且可用于创建委托 ...

  6. Diwali

    转帖 今天是印度新年(Diwali), 全公司庆祝,午饭不要钱   一.不到美国不知道,三人行必有我师,二人行必有老印.. 一大早“春眠不觉晓,处处闻老印”:晚上遛个弯“举头望明月,低头见老印”:到山 ...

  7. 微信平台上遇到的bug

    做微信平台遇到的bug,没有什么方法修改,至今只是避免出现,还未解决 1.header的position:fixed定位:如果整个页面的高度不足屏幕高度时,安卓部分手机header与title之间会有 ...

  8. LED BIN code

    在LED选型时,一开始我们都知道要选个某种颜色,在选个尺寸,但在到具体选的时候,就会被那些个各种各样的参数搞得迷糊,这个主要对一个最让人困惑的参数-BIN CODE做整理. BIN就是bining的缩 ...

  9. MFC中使用FLASH

    一.准备工作 第一步:下载并安装Adobe Flash Player. 从官方网站(http://get.adobe.com/cn/flashplayer/)上下载最新的Flash Player(大约 ...

  10. unix basic command

    1. get start Command Example Description ls ls ls -a ls -l 输出目录文件 输出文件包括隐藏文件 输出文件详细信息 pwd pwd show p ...