Có rất nhiều repos công cộng trên git mà có thể có thể làm những gì bạn muốn. Một số nội dung tôi đã tìm thấy:
https://github.com/mariohahn/MHVideoPhotoGallery
https://github.com/mwaterfall/MWPhotoBrowser
Đó có thể là quá phức tạp. Một tùy chọn khác là tạo UIImageView tại cùng một vị trí với ô và sau đó làm động nó để lấp đầy màn hình. Mã này giả định collectionView có nguồn gốc tại (0,0), nếu không thì chỉ cần thêm bù đắp của collectionView khi tính toán khung ban đầu.
collectionView.scrollEnabled = false; // disable scrolling so view won't move
CGPoint innerOffset = collectionView.contentOffset; // offset of content view due to scrolling
UICollectionViewLayoutAttributes *attributes = [collectionView layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0] ];
CGRect cellRect = attributes.frame; // frame of cell in contentView
UIImageView *v = [[UIImageView alloc] initWithFrame:CGRectMake(cellRect.origin.x - innerOffset.x, cellRect.origin.y - innerOffset.y, cellRect.size.width, cellRect.size.height)];
[self.view addSubview:v]; // or add to whatever view you want
v.image = image; // set your image
v.contentMode = UIViewContentModeScaleAspectFit; // don't get stupid scaling
// animate
[UIView animateWithDuration:0.5 animations:^{
[v setFrame:[[UIScreen mainScreen] bounds]]; // assume filling the whole screen
}];
Đây không phải là hoạt ảnh xuất sắc nhưng vẫn trông ổn.
[Điều này có thể giúp bạn] (https://github.com/mariohahn/MHVideoPhotoGallery). Nó có nhiều ví dụ chức năng. Để thực hiện công việc này, bạn cần phải sử dụng các lớp chuyển tiếp và hoạt ảnh. – Dima
[This] (http://stackoverflow.com/questions/12481004/how-to-animate-a-uiimageview-to-display-fullscreen-by-tapping-on-it) có thể trả lời câu hỏi của bạn –