IOS-试图旋转效果的实现
来源:互联网 发布:炸金花棋牌游戏源码 编辑:程序博客网 时间:2024/05/17 04:07
.h
#import <UIKit/UIKit.h>@interface ZSViewController : UIViewController{ float screenWidth; float screenHeight;}-(UIColor*)createColor:(float)r :(float)g :(float)b;@end
.m
#import "ZSViewController.h"@interface ZSViewController ()@end@implementation ZSViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization self.view.backgroundColor = [UIColor colorWithRed:100.0/255.0 green:200.0/255.0 blue:200.0/255.0 alpha:0.8]; } return self;}-(UIColor*)createColor:(float)r :(float)g :(float)b{ UIColor *color = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:0.8]; return color;}- (void)viewDidLoad{ [super viewDidLoad]; //-------------0.init screenWidth = self.view.center.x*2; screenHeight = self.view.center.y*2; //-------------1.add a new view UIView *picSwitchView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)]; picSwitchView.backgroundColor = [self createColor:100.0 :200.0 :200.0]; picSwitchView.tag = 1000; [self.view addSubview:picSwitchView]; //-------------2.add image view UIImageView *imageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"picture1.jpg"]]; [imageView1 setFrame:CGRectMake(0,0, screenWidth, screenHeight)]; imageView1.tag = 1001; imageView1.backgroundColor = [self createColor:255.0 :0 :0]; [picSwitchView addSubview:imageView1]; UIImageView *imageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"picture2.jpg"]]; [imageView2 setFrame:CGRectMake(0,0, screenWidth, screenHeight)]; imageView2.tag = 1002; imageView2.backgroundColor = [self createColor:0.0 :255.0 :0.0]; [picSwitchView addSubview:imageView2]; //-------------3.add btn to control fanzhuan UIButton *btnControl = [UIButton buttonWithType:UIButtonTypeSystem]; [btnControl setFrame:CGRectMake(screenWidth/2, screenHeight-30, 40, 20)]; [btnControl setTitle:@"fanzhuan" forState:UIControlStateNormal]; [btnControl addTarget:self action:@selector(fanzhuan) forControlEvents:UIControlEventTouchUpInside]; [picSwitchView addSubview:btnControl]; }-(void)fanzhuan{ NSLog(@"btn clicked!"); //1.animation operator CGContextRef theContext = UIGraphicsGetCurrentContext(); [UIView beginAnimations:nil context:theContext]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:1.0]; //2.add anination to a view UIView *thePicSwitchView = [self.view viewWithTag:1000]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:thePicSwitchView cache:YES]; NSInteger purple = [[thePicSwitchView subviews] indexOfObject:[thePicSwitchView viewWithTag:1002]]; NSInteger maron = [[thePicSwitchView subviews] indexOfObject:[thePicSwitchView viewWithTag:1001]]; NSLog(@"tag 1002 is :%d,tag 1001 is :%d",(int)purple,(int)maron); [thePicSwitchView exchangeSubviewAtIndex:maron withSubviewAtIndex:purple]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animationFinished)]; [UIView commitAnimations];}-(void)animationFinished{ NSLog(@"animation finished!");}- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}/*#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller.}*/@end
0 0
- IOS-试图旋转效果的实现
- ios 核心动画-------跳动效果的实现,旋转效果的实现
- iOS 利用平移缩放旋转手势对view实现对应的平移缩放旋转效果(一)
- iOS---transform类的使用,平移,缩放,旋转效果的实现
- android 实现控件的旋转动画效果
- android 实现控件的旋转动画效果
- Java实现风车旋转的效果
- 旋转ImageView和TextView的效果实现
- Java实现的一个旋转效果(旋转太极)
- MaterialProgressDrawable , 实现SwipeRefreshLayout的下拉效果的旋转动画效果
- IOS简洁的试图控制器
- ios 试图滚动的时候,顶部显示和隐藏动画效果
- iOS 屏幕旋转,单个屏幕旋转的实现
- iOS开发让视图达到绕右上角旋转的效果
- ios试图
- IOS 旋转重构视图的实现
- iOS中旋转加载动画的实现
- iOS中旋转加载动画的实现
- 日本研制出用于电动汽车的锂电池高耐热技术
- C# 中的委托和事件
- Coder-Strike 2014 - Finals (online edition, Div. 1)
- C# List的使用
- .NET 数据类型之匿名类型(var)
- IOS-试图旋转效果的实现
- Unity3D 开发优秀技术资源汇总
- unity3D游戏开发十八之NGUI动画
- 数据库基础知识
- dpkg 命令使用说明
- 人类不善于浏览纯文本文档,更善于浏览表格和图表
- c语言中:data[i]=i[data]
- 有关DHCP服务器 offer ack 包单播广播问题
- 繞過linux Driver Vermagic檢查