gpt4 book ai didi

ios - 如何在选中时缩放 CollectionviewCell 图像?

转载 作者:行者123 更新时间:2023-11-29 12:35:04 24 4
gpt4 key购买 nike

我制作了一个应用程序,该应用程序与Custumcell conatin uicollectionView,并且每个单元格都包含我要在选择的任何图像时要制作的图像然后 collectionview 显示为 URBMediaFocusViewController Libraray

图书馆链接在这里URBMediaFocusViewController

我知道这个问题被问过很多次了,但请给我解决方案。

最佳答案

这不是很优雅,但我就是这样做的。基本上获取源 UICollectionView Cell 的框架位置和大小,您希望它出现的框架和位置(在本例中我填充 View ),然后在两个大小之间设置动画。希望这会有所帮助。

- (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];

关于ios - 如何在选中时缩放 CollectionviewCell 图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26604105/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com