使用 CGAffineTransformMakeRotation 时无法增加 UIView 的高度和宽度
Unable to increase height and width of UIView when using CGAffineTransformMakeRotation
我正在使用 UISLider
值旋转 UIView
。如果滑块值增加或减少,则根据该旋转发生。我的代码运行良好。
旋转动作:
@IBAction func sliderToolAction(sender: UISlider) {
if sender.tag == 1
{
let radians = CGFloat(sender.value) * 22 / (7 * 180)
rotatingView.transform = CGAffineTransformMakeRotation(radians)
}
}
输出:
Rotating Frame: (100, 20, 103.9990, 127.8889)
旋转 UIView
后,我尝试增加该视图的 width
和 height
,但它不起作用。
调整大小操作
@IBAction func sliderToolAction(sender: UISlider) {
if sender.tag == 2
{
rotatingView.frame.size.width = CGFloat(sender.value) * viewWidth
rotatingView.frame.size.height = CGFloat(sender.value) * viewHeight
}
}
输出:
Rotating Frame: (80, 40, 207.8888, 255.6667) //ATTEMPT 1
Rotating Frame: (50, 60, 207.8888, 255.6667) //ATTEMPT 2
Rotating Frame: (20, 90, 207.8888, 255.6667) //ATTEMPT 3
Rotating Frame: (-10, 120, 207.8888, 255.6667) //ATTEMPT 4
我正在单独增加宽度和高度,但 UIView 位置移出了屏幕。请指导我。
Warning
If the transform property is not the identity transform, the value of
this property is undefined and therefore should be ignored.
和:
Changes to this property can be animated. However, if the transform
property contains a non-identity transform, the value of the frame
property is undefined and should not be modified. In that case, you
can reposition the view using the center property and adjust the size
using the bounds property instead.
不要更改框架大小,而是更改边界大小。
我正在使用 UISLider
值旋转 UIView
。如果滑块值增加或减少,则根据该旋转发生。我的代码运行良好。
旋转动作:
@IBAction func sliderToolAction(sender: UISlider) {
if sender.tag == 1
{
let radians = CGFloat(sender.value) * 22 / (7 * 180)
rotatingView.transform = CGAffineTransformMakeRotation(radians)
}
}
输出:
Rotating Frame: (100, 20, 103.9990, 127.8889)
旋转 UIView
后,我尝试增加该视图的 width
和 height
,但它不起作用。
调整大小操作
@IBAction func sliderToolAction(sender: UISlider) {
if sender.tag == 2
{
rotatingView.frame.size.width = CGFloat(sender.value) * viewWidth
rotatingView.frame.size.height = CGFloat(sender.value) * viewHeight
}
}
输出:
Rotating Frame: (80, 40, 207.8888, 255.6667) //ATTEMPT 1
Rotating Frame: (50, 60, 207.8888, 255.6667) //ATTEMPT 2
Rotating Frame: (20, 90, 207.8888, 255.6667) //ATTEMPT 3
Rotating Frame: (-10, 120, 207.8888, 255.6667) //ATTEMPT 4
我正在单独增加宽度和高度,但 UIView 位置移出了屏幕。请指导我。
Warning
If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.
和:
Changes to this property can be animated. However, if the transform property contains a non-identity transform, the value of the frame property is undefined and should not be modified. In that case, you can reposition the view using the center property and adjust the size using the bounds property instead.
不要更改框架大小,而是更改边界大小。