1. Related methods
-(void) invalidatelayout//Refresh Layout
e.g.
-(void) Handlepinches: (Uipinchgesturerecognizer *) paramsender{
Cgsize defaultlayoutitemsize = Cgsizemake (80.0f, 120.0f); This is the default size that was originally set, where each scaling is based on the default size
Uicollectionviewflowlayout *layout = (uicollectionviewflowlayout *) self.collectionView.collectionViewLayout;
Layout.itemsize = Cgsizemake (Defaultlayoutitemsize.width * Paramsender.scale, Defaultlayoutitemsize.height * Paramsender.scale);
[Layout invalidatelayout]; Discard old layouts, update new layouts
}
-(void) viewdidload{
[Super Viewdidload];
Self.collectionView.backgroundColor = [Uicolor Whitecolor];
Uipinchgesturerecognizer *pinch = [[Uipinchgesturerecognizer alloc] initwithtarget:self action: @selector ( Handlepinches:)];
For (Uigesturerecognizer *recognizer in self.collectionView.gestureRecognizers) {
if ([Recognizer Iskindofclass:[pinch class]]) {
[Recognizer Requiregesturerecognizertofail:pinch]; This is used here to make sure that the zoom gesture remains independent and does not confuse
[Agesture Requiregesturerecognizertofail:btapgesture]; b gesture is invalid, to recognize a gesture (such as double click after the admission is not recognized click, etc., to ensure that no confusion gestures)
}
}
[Self.collectionview Addgesturerecognizer:pinch];
}