【问题标题】:Initialisation of a CGPoint with { } notation使用 { } 符号初始化 CGPoint
【发布时间】:2012-04-26 14:53:06
【问题描述】:

CGPointMake让我失望之后,我发现我们可以像这样初始化一个静态常量CGPoint

static const CGPoint p = { 0.f, 0.f };

它有效,但大括号符号实际上在做什么?

【问题讨论】:

    标签: iphone objective-c ios macos cgpoint


    【解决方案1】:

    CGPoint 是一个结构体:

    struct CGPoint {
        CGFloat x;
        CGFloat y;
    };
    

    这是在 C 中初始化结构的有效方法。请参阅Struct initialization of the C/C++ programming language?

    【讨论】:

    • 你认为struct初始化会比CGPointMake函数调用更快吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多