我在应用两个转换后调整子视图的大小有问题:CGAffineTransformMakeRotation和CGAffineTransformScale。
A screenshot that represents the problem.
如您所见,#1是包含子视图#2的卡片视图。应用两个转换后(拖动时),子视图未正确调整大小。
请参阅下文,了解CardView中使用的代码:
/**
* This code is placed within the CardView class
* in the touchedMoved:touches:withEvent method.
*/
// Dictates the rotation strength based on the distance from center and card width.
let rotationStrength = min(self.distanceFromCenter.x / CGRectGetWidth(self.bounds), CardView.rotationMax)
// Degree change in radians.
let rotationAngle = CardView.rotationAngle * rotationStrength
// Amount the height/width changes when you move the card up to a certain point.
let scaleStrength = 1 - ((1 - CardView.scaleMin) * fabs(rotationStrength))
let scale = max(scaleStrength, CardView.scaleMin)
// Transformation to rotate by certain amount.
let rotationTransform = CGAffineTransformMakeRotation(rotationAngle)
// Transformation to scale by a certain amount.
let scaleAndRotationTransform = CGAffineTransformScale(rotationTransform, scale, scale)
// Apply transformations.
self.transform = scaleAndRotationTransform
我已经尝试了许多可能的解决方案:
有什么建议吗?我有点卡在这里! :)