gpt4 book ai didi

cocoa - 如何将 NSRect 更改为 CGRect?

转载 作者:行者123 更新时间:2023-12-03 16:09:53 30 4
gpt4 key购买 nike

-(void)drawRect : (NSRect)rect 
{
imgRect.orgin = NSZeroPoint;

imgRect.size = [appleImage size];

drawRect = [self bounds];

[appleRect drawInRect:appleRect
fromRect:imgRect
operation:NSCompositeSourceOver
fraction:1.0];
...
}
<小时/>

我正在尝试这个,但这并不容易,而且让我发疯。

如何将 NSRect 类型代码更改为 CGRect 类型代码?

请帮忙!

ps。我已经知道.. NSRect -> CGRect , NSZeroPoint -> CGRectZero

最佳答案

只需使用这 2 个 Cocoa(非 iOS)函数即可:

CGRect NSRectToCGRect(NSRect nsrect);
NSRect NSRectFromCGRect(CGRect cgrect);

看看这里以加深主题:http://cocoadev.com/CGRect

关于cocoa - 如何将 NSRect 更改为 CGRect?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6440172/

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