首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将macOS drawRect转换为iOS

将macOS drawRect转换为iOS
EN

Stack Overflow用户
提问于 2021-02-18 08:09:55
回答 1查看 49关注 0票数 0

这是Mac的代码。我想把它们转换成iOS。

代码语言:javascript
复制
- (void)drawRect:(NSRect)rect {
    NSGraphicsContext *gc = [NSGraphicsContext currentContext];
    [gc setShouldAntialias:YES];

    NSAffineTransform *trans;

    if ([NSGraphicsContext currentContextDrawingToScreen]) {
        trans = [NSAffineTransform transform];
        [trans scaleXBy:zoom yBy:zoom];
        [trans concat];
    }

    if ([NSGraphicsContext currentContextDrawingToScreen]) {
        trans = [NSAffineTransform transform];
        [trans translateXBy:0 yBy:10.0];
        [trans concat];
    }
}

NSAffineTransform如何转换为CGAffineTransform

谢谢你的帮助~

EN

回答 1

Stack Overflow用户

发布于 2021-02-18 08:26:00

您可以使用CGAffineTransform

代码语言:javascript
复制
CGAffineTransform trans = CGAffineTransformIdentity; // identity transfrom
CGAffineTransformScale(trans, 1.0/zoom, 1.0/zoom); // scale
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66255939

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档