gpt4 book ai didi

ios - 如何将 UIView 旋转 45 度?

转载 作者:可可西里 更新时间:2023-11-01 05:21:30 25 4
gpt4 key购买 nike

我想用动画将我的 UIButton 旋转 M_PI/4。这是我的代码:

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[UIView animateWithDuration:.5 animations:^{
self.closeButton.transform = CGAffineTransformMakeRotation(M_PI/4);
}];
}

但这会使我的按钮的框架损坏。动画前的帧为 (260 0; 44 44),动画后变为 (250.887 -9.1127; 62.2254 62.2254)。我看到了this帖子和其他一些,但我不明白,如何通过 M_PI/2 实现 UIButton 动画旋转。

最佳答案

Xcode - 10
swift - 4x

self.yourView.transform = CGAffineTransform(rotationAngle: .pi/4)

这可以帮助您将 uiview 旋转 45 度

关于ios - 如何将 UIView 旋转 45 度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22512203/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com