gpt4 book ai didi

xcode - IB_DESIGNABLE 永远不适用于 NSTextFieldCell

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

我有一个 NSTextFieldCell 子类,在实现中只有这个代码:

- (NSRect)drawingRectForBounds:(NSRect)theRect
{
// Get the parent's idea of where we should draw
NSRect newRect = [super drawingRectForBounds:theRect];

// When the text field is being
// edited or selected, we have to turn off the magic because it screws up
// the configuration of the field editor. We sneak around this by
// intercepting selectWithFrame and editWithFrame and sneaking a
// reduced, centered rect in at the last minute.
if (mIsEditingOrSelecting == NO)
{
// Get our ideal size for current text
NSSize textSize = [self cellSizeForBounds:theRect];

// Center that in the proposed rect
float heightDelta = newRect.size.height - textSize.height;
if (heightDelta > 0)
{
newRect.size.height -= heightDelta;
newRect.origin.y += (heightDelta / 2);
}
}

return newRect;
}

在标题上,我在@interface之前有IB_DESIGNABLE

此类用于将文本在 NSTextField 上垂直居中,但文本永远不会在界面生成器上居中显示。该类永远不会在界面生成器上呈现。为什么?

最佳答案

不幸的是,IBDESIGNABLE 仅适用于 NSView 和 UIView 的后代。

关于xcode - IB_DESIGNABLE 永远不适用于 NSTextFieldCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27745318/

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