매우 우아하지는 않지만 내가하는 방법입니다. 기본적으로 소스 UICollectionView 셀의 프레임 위치와 크기, 프레임 및 원하는 위치 (이 경우 필자는보기를 채 웁니다)의 위치를 얻은 다음 두 크기 사이에서 애니메이션을 적용합니다. 희망이 도움이됩니다.
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
[collectionView selectItemAtIndexPath:indexPath animated:YES scrollPosition:UICollectionViewScrollPositionCenteredHorizontally];
[self zoomToSelectedImage:indexPath];
}
-(void)zoomToSelectedImage:(NSIndexPath *)indexPath
{
UIImageView *zoomImage = [[UIImageView alloc] initWithImage:[self.myPictures objectAtIndex:indexPath.row]];
zoomImage.contentMode = UIViewContentModeScaleAspectFit;
CGRect zoomFrameTo = CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height);
UICollectionView *cv = (UICollectionView *)[self.view viewWithTag:66]; // Change to whatever the tag value of your collectionView is
cv.hidden = TRUE;
UICollectionViewCell *cellToZoom =(UICollectionViewCell *)[cv cellForItemAtIndexPath:indexPath];
CGRect zoomFrameFrom = cellToZoom.frame;
[self.view addSubview:zoomImage];
zoomImage.frame = zoomFrameFrom;
zoomImage.alpha = 0.2;
[UIView animateWithDuration:0.2 animations:
^{
zoomImage.frame = zoomFrameTo;
zoomImage.alpha = 1;
} completion:nil];
내가 내 애플 리케이션이 코드를 만들하지만 내 코드 입니다 작동하지 않는 - (무효) zoomToSelectedImage : (NSIndexPath *) indexPath { 있는 NSDictionary * DICT = [self.imagesa objectAtIndex : indexPath.item] ; NSString * img = [dict valueForKey : @ "링크"]; UIImageView * zoomImage = [[UIImageView alloc] initWithImage : [UIImage imageNamed : img]]; –
#Gismay 내가 그것을 해결하지만 내가 배경을 Collectionview 또한 내가 그 사람을 숨기려면 누른 다음 확대 된 이미지를 클릭하면 다음 컬렉션보기에 대한 모든 솔루션에 대한 해결책을 보여주고 이미지를 확대/축소? –
숨기기 위해 UICollectionView의 숨겨진 플래그를 TRUE로 설정 한 다음 작업이 끝나면 다시 설정하십시오. 사용자가 이미지를 탭한 시점을 감지하기 위해 탭 제스처 레그 인식기를 추가하십시오. – Gismay