#import
@protocol ImageShowCellDelegate
- (void)tapClick;
@end
@interface ImageShowCell : UICollectionViewCell
/**
* 背景scrollview 用来支持缩放等手势
*/
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
/**
* 要展示的imageview
*/
@property (weak, nonatomic) IBOutlet UIImageView *imgView;
@property (weak, nonatomic) IBOutlet UILabel *progressLabel;
@property (nonatomic,strong) id
@end
@interface ImageShowCell()
@end
@implementation ImageShowCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
self.contentView.preservesSuperviewLayoutMargins = NO;
//设置实现缩放
//设置代理scrollview的代理对象
self.scrollView.delegate=self;
//设置最大伸缩比例
self.scrollView.maximumZoomScale=5.0;
//设置最小伸缩比例
self.scrollView.minimumZoomScale=1.0;
self.scrollView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
self.imgView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapClicks)];
self.imgView.userInteractionEnabled = YES;
self.imgView.contentMode = UIViewContentModeScaleAspectFit;
[self addGestureRecognizer:tap];
}
//告诉scrollview要缩放的是哪个子控件
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return self.imgView;
}
- (void)tapClicks{
[self.delegate tapClick];
}
@end