【发布时间】:2013-11-22 15:31:05
【问题描述】:
我在容器中有一个 NSTextField:
[textField setFrameOrigin:NSMakePoint(0, -t.frame.size.height)];
content = [[NSView alloc] init];
[content setWantLayer:YES]
content.layer=[CALayer layer];
[content addSubview:textField];
[content scaleUnitSquareToSize:NSMakeSize(1, -1)];
content.frame=textField.frame;
content.layer.backgroundColor=textBGColor.CGColor;
容器本身位于一个视图中
[view scaleUnitSquareToSize:NSMakeSize(1, -1)];
这一切都是为了获得 TextField 的左上角原点,效果很好,唯一的问题在于 InsertionPoint 没有绘制(至少不在可见框架中)。
我认为 InsertionPoint 要么没有缩放,要么没有与 TextField 一起翻译。另一种可能是 InsertionPoint 无法在支持图层的 View 中绘制。
有没有办法显示 InsertionPoint 光标?
编辑
在尝试了所有可能性之后,似乎 InsertionPoint(和 focusRing)没有绘制,因为它的框架被定位在 superviews 边界和它的dirtyDrawRect之外。有没有办法删除 NSView 的剪辑?我需要能够将我的 TextField 放置在每个可能的绝对位置上。
【问题讨论】:
标签: macos cocoa nstextfield nstextview