//
// ViewController.m
// 点击图片全屏显示快速创建
//
// Created by 哈哈 on 15/10/18.
// Copyright © 2015年 哈哈. All rights reserved.
//
#import "ViewController.h"
#import "Header.h"
#import "ImageScrollView.h"
#import "UIImageView+WebCache.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *testImageView;
@property (nonatomic,strong) UIActivityIndicatorView *activityIndicatorViewOne; //第一个附件imageView上的旋转view
@property (nonatomic,strong) UIView *forwardViewOne; //第一个附件imageView上的刷新蒙版view
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.testImageView.userInteractionEnabled = YES;
//1、创建手势实例,并连接方法handleTapGesture,点击手势
UITapGestureRecognizer *tapGestureOne=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTapGesture:)];
//设置手势点击数
tapGestureOne.numberOfTapsRequired=1;
// imageView添加手势识别
[self.testImageView addGestureRecognizer:tapGestureOne];
#pragma mark 添加第一个蒙版view和第一个转圈儿view
self.forwardViewOne.frame = self.testImageView.frame;
[self.view addSubview:self.forwardViewOne];
self.activityIndicatorViewOne.center = self.forwardViewOne.center;
[self.activityIndicatorViewOne startAnimating];
[self.view addSubview:self.activityIndicatorViewOne];
//当加载完成后,将转圈儿缓冲移除掉
[self.testImageView sd_setImageWithURL:[NSURL URLWithString:@"http://pica.nipic.com/2007-11-09/200711912453162_2.jpg"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
[self.activityIndicatorViewOne stopAnimating]; //结束动画
[self.activityIndicatorViewOne removeFromSuperview]; //移除圆圈view
[self.forwardViewOne removeFromSuperview]; //移除蒙版view
}];
}
#pragma mark 点击手势触发事件
- (void)handleTapGesture:(UITapGestureRecognizer *)sender {
//点击事件需要处理,如果其中没有图片怎么处理?先做出效果,在看看怎么添加
ImageScrollView *imageScrollView = [[ImageScrollView alloc] init];
[imageScrollView imageScrollViewWithX:0 Y:0 width:WIDTH height:HEIGHT image:self.testImageView.image andWindow:self.view.window];
}
#pragma mark 创建第一个附件imageView的蒙版view
- (UIView *)forwardViewOne {
if (!_forwardViewOne) {
_forwardViewOne = [[UIView alloc] init];
_forwardViewOne.backgroundColor = [UIColor clearColor];
}
return _forwardViewOne;
}
#pragma mark 创建第一个附件imageView的圆圈view
- (UIActivityIndicatorView *)activityIndicatorViewOne {
if (!_activityIndicatorViewOne) {
_activityIndicatorViewOne = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
_activityIndicatorViewOne.hidesWhenStopped = YES;
}
return _activityIndicatorViewOne;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end