如何在iphone中实现图片的放大(不使用多点触控:即两个手指拉开)

静水-流深 2010-08-26 02:30:43
现在想在iphone中实现iphone的图片放大功能,将一张小图片放大到手机全屏这样一个动画效果,我想用calayer来实现,可是对它不太熟,请熟悉的朋友帮帮忙。很急。多谢了。
...全文
413 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
静水-流深 2010-08-26
  • 打赏
  • 举报
回复
我已经实现了,还可以。谢谢了啊
静水-流深 2010-08-26
  • 打赏
  • 举报
回复
谢谢帮忙了,我研究一下你的代码。
云瑀 2010-08-26
  • 打赏
  • 举报
回复
http://blog.csdn.net/cloudhsu/archive/2010/08/26/5841089.aspx
该范例相关资料可到我的博客参考
云瑀 2010-08-26
  • 打赏
  • 举报
回复
请参照代码

#import <UIKit/UIKit.h>

#define IMAGE_VIEW_1 100
#define IMAGE_VIEW_2 101

#define BIGRECT CGRectMake(0.0f, 0.0f, 320.0f, 435.0f)
#define SMALLRECT CGRectMake(130.0f, 187.0f, 60.0f, 60.0f)

@interface ToggleView: UIView
{
BOOL isOne;
}
@end

@implementation ToggleView

- (id) initWithFrame: (CGRect) aFrame;
{
self = [super initWithFrame:aFrame];

// Load both views, make them non-interactive
UIImageView *imgView1 = [[UIImageView alloc] initWithFrame:BIGRECT];
imgView1.image = [UIImage imageNamed:@"one.png"];
imgView1.userInteractionEnabled = NO;
imgView1.tag = IMAGE_VIEW_1;

UIImageView *imgView2 = [[UIImageView alloc] initWithFrame:SMALLRECT];
imgView2.image = [UIImage imageNamed:@"two.png"];
imgView2.userInteractionEnabled = NO;
imgView2.tag = IMAGE_VIEW_2;

// image 1 is in front of image 2 to begin
[self addSubview:imgView2];
[self addSubview:imgView1];
isOne = YES;

[imgView1 release];
[imgView2 release];

return self;
}

- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
// Determine which view occupies which role
UIImageView *big = (UIImageView *)[self viewWithTag: (isOne ? IMAGE_VIEW_1 : IMAGE_VIEW_2)];
UIImageView *little = (UIImageView *)[self viewWithTag: (isOne ? IMAGE_VIEW_2 : IMAGE_VIEW_1)];
isOne = !isOne;

// Pack all the changes into the animation block
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];

[big setFrame:SMALLRECT];
[big setAlpha:0.5];
[little setFrame:BIGRECT];
[little setAlpha:1.0];

[UIView commitAnimations];

// Hide the shrunken "big" image.
[big setAlpha:0.0f];
[[big superview] bringSubviewToFront:big];
}
@end

@interface HelloController : UIViewController
@end

@implementation HelloController
- (void)loadView
{
ToggleView *contentView = [[ToggleView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor whiteColor];
self.view = contentView;
[contentView release];
}
@end


@interface SampleAppDelegate : NSObject <UIApplicationDelegate>
@end

@implementation SampleAppDelegate
- (void)applicationDidFinishLaunching:(UIApplication *)application {
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
HelloController *hello = [[HelloController alloc] init];
[window addSubview:hello.view];
[window makeKeyAndVisible];
}
@end

int main(int argc, char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"SampleAppDelegate");
[pool release];
return retVal;
}

本课程讲了Vue3+Vue2+Uni-app(uniapp)入门基础与实战,其还重点讲解了ES6、TypeScript这些基础知识,实战由两大价值5000元的真实企业级项目组成,分别是仿京东电商网站和仿美团微信点餐小程序,同时两大项目代码全部赠送,还赠送前后端架构模板,工作直接使用。VUE和uni-app是目前热门的前端框架,本课程教你如何快速学会VUE和uni-app并应用到实战,教你如何解决内存泄漏,常用UI库的使用,自己封装组件和插件,正式上线白屏问题,性能优化、解决iphoneX“刘海”兼容性问题、微信支付、微信授权登录,获取位置在地图上显示,获取用户所在的城市和街道信息,微信小程序发布审核等。对正在工作当或打算学习VUE和uni-app高薪就业的你来说,那么这门课程便是你手的葵花宝典。学习技巧:学习当不要只看,一定要多敲代码,如果碰到某一个知识点不是很明白,不要钻牛角尖,千万不要因为一个点,放弃整个森林,接着往下学,硬着头皮开发项目。只要能亲自开发一个完整的项目,你会发现不明白的地方自然而然就明白了,项目做出来就真正的学会了。此vue和uni-app课程以面试和实战为基础进行讲解,每个知识点都会让你知道在实际项目开发如何使用,学习后,可以开发大型项目,增强逻辑思维,至少让你拥有3年以上开发经验的实力!代码和ppt均可下载!免费提供《企业级完整实战项目接口文档》,绝对可用

29,028

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧