美文网首页
图片浏览器

图片浏览器

作者: ljzza | 来源:发表于2019-05-09 11:22 被阅读0次
#import "KSPhotoBrowser.h"
for (int i = 0; i < self.imageUrlArray.count; i ++) {
        UIImageView *picImageView = [[UIImageView alloc]initWithFrame:CGRectMake((DEVICE_SCREEN_WIDTH - 25 * 2 - 40) /3 * i + 10 * (i+1) , 0, (DEVICE_SCREEN_WIDTH - 25 * 2 - 40) /3, bottomView.height - 20)];
        NSString *imageUrlString = [self.imageUrlArray[i] valueForKey:@"xlh"];
        [picImageView sd_setImageWithURL:[NSURL URLWithString:imageUrlString] placeholderImage:DEFAULT_IMAGE_PLACEHOLDER];
        picImageView.userInteractionEnabled = YES;
        picImageView.tag = 1000+i;
        [_livePictureScorllView addSubview:picImageView];

        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageButtonClick:)];
        tap.numberOfTapsRequired = 1;
        tap.numberOfTouchesRequired = 1;
        [picImageView addGestureRecognizer:tap];
    }
//看图片
- (void)imageButtonClick:(UITapGestureRecognizer *)tap
{
    NSMutableArray *items = [[NSMutableArray alloc]init];
    for (int i = 0; i < self.imageUrlArray.count; i++)
    {
        UIImageView *imageView = [_livePictureScorllView viewWithTag:1000+i];
        KSPhotoItem *item = [KSPhotoItem itemWithSourceView:imageView imageUrl:[NSURL URLWithString:[self.imageUrlArray[i] valueForKey:@"xlh"]]];
        [items addObject:item];
    }
    KSPhotoBrowser *browser = [KSPhotoBrowser browserWithPhotoItems:items selectedIndex:tap.view.tag-1000];
//    browser.noSingleTap = YES;
//    browser.noSingleTap = NO;
    browser.dismissalStyle = KSPhotoBrowserInteractiveDismissalStyleScale;
    browser.pageindicatorStyle = KSPhotoBrowserPageIndicatorStyleText;
    browser.backgroundStyle = KSPhotoBrowserBackgroundStyleBlack;
    [browser showFromViewController:self];
}

相关文章

网友评论

      本文标题:图片浏览器

      本文链接:https://www.haomeiwen.com/subject/dizioqtx.html