怪异合集View frame origin of transform 180 degrees
Wiered collectionView frame origin if transform 180 degres
我通过代码旋转180度
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewLayoutAttributes *retAttr = [[super layoutAttributesForItemAtIndexPath:indexPath] copy];
if (CGAffineTransformIsIdentity(retAttr.transform)) {
retAttr.transform = CGAffineTransformMakeRotation(M_PI);
}
retAttr.frame = CGRectMake(0, retAttr.frame.origin.y, self.collectionView.bounds.size.width, retAttr.frame.size.height);
return retAttr;
}
由 CGRectMake 制作的框架
(origin = (x = 0, y = 3658), size = (width = 320, height = 1077.5))
但是我得到了
(lldb) po retAttr.frame
(origin = (x = -0.000000000000056843418860808015, y = 3658), size = (width = 320.00000000000011, height = 1077.5))
单元格从屏幕上消失。
如何正确旋转或将框架分配给 x 而不是中断和宽度?
我找到了解决方案 "not use affine transform",我使用的是 3dTransform
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewLayoutAttributes *retAttr = [[super layoutAttributesForItemAtIndexPath:indexPath] copy];
if (CATransform3DIsIdentity(retAttr.transform3D)) {
retAttr.transform3D = CATransform3DMakeRotation(M_PI, 0, 0, 1);
}
return retAttr;
}
现在,一切正常。
我通过代码旋转180度
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewLayoutAttributes *retAttr = [[super layoutAttributesForItemAtIndexPath:indexPath] copy];
if (CGAffineTransformIsIdentity(retAttr.transform)) {
retAttr.transform = CGAffineTransformMakeRotation(M_PI);
}
retAttr.frame = CGRectMake(0, retAttr.frame.origin.y, self.collectionView.bounds.size.width, retAttr.frame.size.height);
return retAttr;
}
由 CGRectMake 制作的框架
(origin = (x = 0, y = 3658), size = (width = 320, height = 1077.5))
但是我得到了
(lldb) po retAttr.frame
(origin = (x = -0.000000000000056843418860808015, y = 3658), size = (width = 320.00000000000011, height = 1077.5))
单元格从屏幕上消失。
如何正确旋转或将框架分配给 x 而不是中断和宽度?
我找到了解决方案 "not use affine transform",我使用的是 3dTransform
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewLayoutAttributes *retAttr = [[super layoutAttributesForItemAtIndexPath:indexPath] copy];
if (CATransform3DIsIdentity(retAttr.transform3D)) {
retAttr.transform3D = CATransform3DMakeRotation(M_PI, 0, 0, 1);
}
return retAttr;
}
现在,一切正常。