gpt4 book ai didi

iphone - CGContextRotateCTM 没有旋转 UIButton

转载 作者:行者123 更新时间:2023-11-28 23:09:39 24 4
gpt4 key购买 nike

我有一个 UIButton 的子类。

这是我必须尝试旋转它的代码。

-(void)drawRect:(CGRect)rect {

CGContextRef context = UIGraphicsGetCurrentContext();

CGFloat angle = (-126.0 * M_PI) / 180.0;
CGContextRotateCTM(context, angle);
}

但是,什么也没有发生。 View 以其默认方向绘制到屏幕上。知道我错过了什么吗?谢谢!

最佳答案

通常当你想旋转一个按钮时,你不会通过子类化和修改 drawRect 来实现。

您所要做的就是:

button.transform = CGAffineTransformMakeRotation(M_PI/2);

关于iphone - CGContextRotateCTM 没有旋转 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8612341/

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