项目用到的icarouls类和UIEffectDesignerView类,菜单技巧,构思(金方圆)
//
// 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类,菜单技巧,构思(金方圆)的更多相关文章
- .NET平台开源项目速览(18)C#平台JSON实体类生成器JSON C# Class Generator
去年,我在一篇文章用原始方法解析复杂字符串,json一定要用JsonMapper么?中介绍了简单的JSON解析的问题,那种方法在当时的环境是非常方便的,因为不需要生成实体类,结构很容易解析.但随着业务 ...
- AspNet Core Web 应用程序的启动(有关 Program.cs类/ Startup.cs类 ) 当项目中干掉 Startup.cs 类如何设置启动 配置等等
.有关怎么创建Core MVC/API 这里就不说了,前段时间的博客有说过: 1. 项目生成后会有如图所示两个类 Program类Startup类 2. Startup类 初始内容 public ...
- eclipse怎么对项目重命名,eclipse怎么重命名类
eclipse怎么对项目重命名,eclipse怎么重命名类
- Django商城项目笔记No.3用户部分-用户模型类
Django商城项目笔记No.3用户部分-用户模型类 Django提供了认证系统,文档资料https://yiyibooks.cn/xx/Django_1.11.6/topics/auth/index ...
- C++第11周(春)项目3 - 点类派生直线类
课程首页在:http://blog.csdn.net/sxhelijian/article/details/11890759.内有完整教学方案及资源链接 [项目3 - 点类派生直线类]定义点类Poin ...
- 扩展银行项目,添加一个(客户类)Customer类。Customer类将包含一个Account对象。
练习目标-使用引用类型的成员变量:在本练习中,将扩展银行项目,添加一个(客户类)Customer类.Customer类将包含一个Account对象. 任务 在banking包下的创建Customer类 ...
- 编写Java程序,使用ThreadLocal类,项目中创建账户类 Account,类中包括账户名称name、 ThreadLocal 类的引用变量amount,表示存款
查看本章节 查看作业目录 需求说明: 某用户共有两张银行卡,账户名称相同,但卡号和余额不同.模拟用户使用这两张银行卡进行消费的过程,并打印出消费明细 实现思路: 项目中创建账户类 Account,类中 ...
- SSM项目web.xml等配置文件中如何查找类的全路径名?
如题, web.xml,applicationContext.xml 等配置文件中,有时不会出现自动提示类的名字,这时如何查找类的全路径名,如下图所示: 1.鼠标右键单击菜单栏Navigate选项,选 ...
- JavaWeb网上图书商城完整项目--day03-1.图书模块功能介绍及相关类创建
1 前两天我们学习了user用户模块和图书的分类模块,接下来我们学习图书模块 图书模块的功能主要是下面的功能: 2 接下来我们创建对应的包 我们来看看对应的数据库表t_book CREATE TABL ...
随机推荐
- express
1.基于node.js的web开发框架. 2.express目录结构: node_modules public routes views app.js:项目主文件 package.json 3.获取程 ...
- gitt
一,git config core.autocrlf false 二,vi .git/config[remote "origin"] url = https://github.co ...
- java 排序
class Employee { private String name; private String id; private String salary; public static void m ...
- Python的入门要点
一.输入 1.键盘输入 在python 2.7中,不用input(),而用 raw_input()读入一行键盘输入,并转化为字符串. s = map(int ,raw_input().split()) ...
- css 之 文本缩进属性(text-indent)
文章转自:http://www.10wy.net/Article/CSS/CSS_list_8.html查看更多更专业性的文章请到:网页设计网 文本缩进属性(text-indent) 这个属性设定文本 ...
- OpenCV中的矩阵操作
函数 Description 说明 cvAdd Elementwise addition of two arrays 两个数组对应元素的和 cvAddS Elementwise addition of ...
- cisco vpn client 自动登陆脚本
cisco vpn client 不能保存密码,每次都要输入太麻烦了 写了个wsh,可以自动输入密码,并登陆 '需要一个好听的名字 <job id="cisco"> ' ...
- Android AsyncTask异步任务(二)
之前我们讲过了AsyncTask 的生命周期(onPreExecute-->doInBackground-->onProgressUpdate-->onPostExecute),今天 ...
- Allegro padstack
在ALLEGRO中,建立PCB封装是一件挺复杂的事,而要建立FOOTPRINT,首先要有一个PAD,所以就要新建PADSTACK. 焊盘可以分两种,表贴焊盘和通孔焊盘,表贴焊盘结构相对简单,下面首先分 ...
- 入住cnblogs第一篇随笔 Hello, world!
在网上搜索计算机参考资料时经常看到各位大神的博客,甚是神往.今天我也在这里安家,记录自己的学习过程,也同各位共勉. 第一篇随笔,就用来测试一下这里的文本编辑器吧. //The C language # ...