IOS实现半翻页效果
来源:互联网 发布:mysql 触发器 锁表 编辑:程序博客网 时间:2024/05/16 11:50
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
PageViewController *pvController = [[PageViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:pvController]; //加载有标题的view
navController.navigationBar.tintColor=[UIColor redColor]; //颜色设置
[window addSubview:navController.view];
[window makeKeyAndVisible];
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
- (id)init
{
if (!(self = [super init]))
return self;
self.title = @"翻页 Demo";
return self;
}
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view = contentView; //没有xib的时候需要
UIView *frontView1 = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 416.0f)];
//frontView1.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"back1.png"]];
frontView1 = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
frontView1.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"back1.jpg"]];
[self.view addSubview:frontView1];
UIView *frontView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 416.0f)];
frontView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"back2.jpg"]];
[self.view addSubview:frontView];
switchView = [[[UISwitch alloc] init] autorelease];
[switchView setCenter:CGPointMake(200.0f,350.0f)];
[frontView1 addSubview:switchView];
switchStatusLabel = [[[UILabel alloc] initWithFrame:CGRectMake(250.0f, 250.0f, 50.0f, 30.0f)] autorelease];
[frontView addSubview:switchStatusLabel];
[switchStatusLabel setTextAlignment:UITextAlignmentCenter];
switchStatusLabel.text=@"OFF";
isCurl=NO;
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] //按钮的初始化及触发条件设置
initWithTitle:@"Curl"
style:UIBarButtonItemStylePlain
target:self
action:@selector(doCurl)] autorelease];
}
- (void) doCurl
{
//创建CATransition对象
CATransition *animation = [CATransition animation];
//相关参数设置
[animation setDelegate:self];
[animation setSpeed:3.0f];
[animation setDuration:1.0f];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
//向上卷的参数
if(!isCurl)
{
//设置动画类型为pageCurl,并只卷一半
[animation setType:@"pageCurl"];
animation.endProgress=0.7;
}
//向下卷的参数
else
{
//设置动画类型为pageUnCurl,并从一半开始向下卷
[animation setType:@"pageUnCurl"];
animation.startProgress=0.7;
}
//卷的过程完成后停止,并且不从层中移除动画
[animation setFillMode:kCAFillModeForwards];
[animation setSubtype:kCATransitionFromBottom];
[animation setRemovedOnCompletion:NO];
isCurl=!isCurl;
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[[self.view layer] addAnimation:animation forKey:@"pageCurlAnimation"]; //翻页效果
if([switchView isOn])
{
switchStatusLabel.text=@"ON";
}
else
{
switchStatusLabel.text=@"OFF";
}
}
- IOS实现半翻页效果
- 需求:实现IOS翻页效果
- IOS类似翻页效果实现实例
- IOS 上图书翻页效果的实现
- 【代码笔记】iOS-翻页效果的实现
- iOS 书翻页效果
- ios图书翻页效果
- ios 翻页效果
- iOS 书翻页效果
- PagerView实现翻页效果
- 实现Ajax翻页效果
- js实现翻页效果
- Android实现翻页效果
- transform3D实现翻页效果
- 翻页效果实现
- js翻页效果实现
- Leaves -- iOS上一种图书翻页效果的实现
- Leaves -- iOS上一种图书翻页效果的实现
- GMT时间格式转换
- Android性能
- oracle 分析函数
- 使用LruCache和DiskLruCache来下载图片
- Apache Commons-pool实现对象池(包括带key对象池)
- IOS实现半翻页效果
- I2C总线协议详解
- Win7/Win8 64位系统下为Visual Studio 2013配置OpenCV 2.4.9
- 【下载分】C语言for循环语句PK自我活动
- hadoop压缩格式
- 婚后女性家庭应该如何理财生活
- 静态链表的总结
- CKeditor加入中文字体 转
- 分辨率