iOS 最简单的图片缩放方法
2015-01-08 10:07
260 查看
#import <UIKit/UIKit.h>
@interface BSYImage : UIImageView
+(void)showImage:(UIImageView*)avatarImageView;
@end
#import "BSYImage.h"
static CGRect oldframe;
@implementation BSYImage
+(void)showImage:(UIImageView *)avatarImageView{
UIImage *image=avatarImageView.image;
UIWindow *window=[UIApplication sharedApplication].keyWindow;
UIView *backgroundView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
oldframe=[avatarImageView convertRect:avatarImageView.bounds toView:window];
backgroundView.backgroundColor=[UIColor blackColor];
backgroundView.alpha=0;
UIImageView *imageView=[[UIImageView alloc]initWithFrame:oldframe];
imageView.image=image;
imageView.tag=1;
[backgroundView addSubview:imageView];
[window addSubview:backgroundView];
UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideImage:)];
[backgroundView addGestureRecognizer: tap];
[UIView animateWithDuration:0.3 animations:^{
imageView.frame=CGRectMake(0,([UIScreen mainScreen].bounds.size.height-image.size.height*[UIScreen mainScreen].bounds.size.width/image.size.width)/2, [UIScreen mainScreen].bounds.size.width, image.size.height*[UIScreen mainScreen].bounds.size.width/image.size.width);
backgroundView.alpha=1;
} completion:^(BOOL finished) {
}];
}
+(void)hideImage:(UITapGestureRecognizer*)tap{
UIView *backgroundView=tap.view;
UIImageView *imageView=(UIImageView*)[tap.view viewWithTag:1];
[UIView animateWithDuration:0.3 animations:^{
imageView.frame=oldframe;
backgroundView.alpha=0;
} completion:^(BOOL finished) {
[backgroundView removeFromSuperview];
}];
}
@interface BSYImage : UIImageView
+(void)showImage:(UIImageView*)avatarImageView;
@end
#import "BSYImage.h"
static CGRect oldframe;
@implementation BSYImage
+(void)showImage:(UIImageView *)avatarImageView{
UIImage *image=avatarImageView.image;
UIWindow *window=[UIApplication sharedApplication].keyWindow;
UIView *backgroundView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
oldframe=[avatarImageView convertRect:avatarImageView.bounds toView:window];
backgroundView.backgroundColor=[UIColor blackColor];
backgroundView.alpha=0;
UIImageView *imageView=[[UIImageView alloc]initWithFrame:oldframe];
imageView.image=image;
imageView.tag=1;
[backgroundView addSubview:imageView];
[window addSubview:backgroundView];
UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideImage:)];
[backgroundView addGestureRecognizer: tap];
[UIView animateWithDuration:0.3 animations:^{
imageView.frame=CGRectMake(0,([UIScreen mainScreen].bounds.size.height-image.size.height*[UIScreen mainScreen].bounds.size.width/image.size.width)/2, [UIScreen mainScreen].bounds.size.width, image.size.height*[UIScreen mainScreen].bounds.size.width/image.size.width);
backgroundView.alpha=1;
} completion:^(BOOL finished) {
}];
}
+(void)hideImage:(UITapGestureRecognizer*)tap{
UIView *backgroundView=tap.view;
UIImageView *imageView=(UIImageView*)[tap.view viewWithTag:1];
[UIView animateWithDuration:0.3 animations:^{
imageView.frame=oldframe;
backgroundView.alpha=0;
} completion:^(BOOL finished) {
[backgroundView removeFromSuperview];
}];
}
相关文章推荐
- ios 简单的图片缩放方法
- 向ios模拟器里添加图片的简单方法
- iOS 网络/本地 图片 按自定义比例缩放 不失真 方法
- iOS 图片处理方法(按比例缩放,指定宽度按比例缩放)
- iOS之图片缩放的集中方法
- iOS 简单的图片缩放
- 向ios模拟器里添加图片的简单方法
- iOS取出手机里的所有图片 ---简单的方法
- IOS 缩放图片常用方法
- iOS 图片处理方法(按比例缩放,指定宽度按比例缩放)
- ios 简单的设置图片等比例缩放请求的网络图片
- IOS显示gif图片,超简单方法
- ios 改变图片大小缩放方法
- 讲解一下iOS图片单指旋转缩放实现方法
- ios 简单的设置图片等比例缩放请求的网络图片
- Android 简单的图片缩放方法
- iOS 最简单的图片缩放功能代码
- iOS -- 网络/本地 图片 按自定义比例缩放 不失真 方法
- iOS UIScrollView+UIImageView 制作简单的图片浏览器,支持缩放、平移
- iOS 图片简单处理方法