0

标题非常具体地说明了我想要做什么。我有一个自定义视图,并在该视图中绘制了一些元素。如何以编程方式更改自动调整大小的属性?我环顾四周,找不到任何对我有帮助的东西。

目标 C:

- (void)drawRect:(NSRect)HTMLContent { 
    NSGraphicsContext* gc = [NSGraphicsContext currentContext];
    [gc saveGraphicsState];
    int height = [[NSScreen mainScreen] frame].size.height;
    int screenwidth = [[NSScreen mainScreen] frame].size.width;
    int emailInnerContentWidth = screenwidth - 510;

    // Horizontal Line
    [[NSColor colorWithCalibratedRed:.8 green:.82 blue:.83 alpha:1] setFill];
    NSBezierPath* drawingPath = [NSBezierPath bezierPathWithRect:NSMakeRect(337, 570, emailInnerContentWidth, 2)];
    [drawingPath fill];

    // Social Icon
    NSRect outrect = NSMakeRect(355, 585, 58, 58);
    [[NSColor lightGrayColor] setStroke];
    [[NSColor colorWithPatternImage:[NSImage imageNamed:@"NoSocialIcon.png"]] setFill];
    NSBezierPath* outcirclePath = [NSBezierPath bezierPath];
    [outcirclePath appendBezierPathWithOvalInRect: outrect];
    [[NSColor lightGrayColor] setStroke];[[NSImage imageNamed:@"NoSocialIcon.png"] drawInRect:outrect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1];
    [outcirclePath stroke];

    // Restore graphics state
    [gc restoreGraphicsState];
}

我想将这两种形状设置为不受窗口底部变化的影响。我希望它在窗口顶部改变高度时改变。我查看了 Apple 文档,但似乎没有任何效果。提前致谢

4

1 回答 1

1

因此,对于这两种形状中的每一种:

[shape setAutoresizingMask:NSViewNotSizable | NSViewMaxXMargin | NSViewMinYMargin];
于 2012-07-16T00:22:34.847 回答