我正在尝试创建一个NSView托管CALayer层次结构的自定义来执行高效显示.这NSView随后被嵌入内NSTableCellView由一个基于视图的显示NSOutlineView.
问题在于,每当我展开或折叠项目时,所有行都会被移动,但图层的内容仍会显示在更改轮廓之前的位置.
滚动NSOutlineView似乎刷新了图层,并在那时重新同步它们的行.
我使用Instruments调试了这种行为,似乎滚动引发了一个布局操作,该操作通过setPosition:在扩展或折叠项目时应该发生的调用来更新层.
以下是一个简单的图层托管NSView子类的示例代码.
@interface TestView : NSView
@end
@implementation TestView
- (instancetype)initWithFrame:(NSRect)frameRect
{
self = [super initWithFrame:frameRect];
CAShapeLayer* layer = [CAShapeLayer layer];
layer.bounds = self.bounds;
layer.position = CGPointMake(NSMidX(self.bounds), NSMidY(self.bounds));
layer.path = [NSBezierPath bezierPathWithOvalInRect:self.bounds].CGPath;
layer.fillColor = [NSColor redColor].CGColor;
layer.delegate = self;
self.layer = layer;
self.wantsLayer = YES;
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
我已经尝试了很多这个问题的潜在解决方案,但我找不到任何有趣的方法,NSView可以覆盖调用[self.layer setNeedsDisplay]或实例[self.layer setNeedsLayout].我也尝试了各种各样的setter,CALayer例如:
layer.autoresizingMask …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用卷共享在Docker guest中共享文件.为了获得相同的UID,以及与这些文件的互操作性,我想在Docker guest中创建一个用户,其用户名与我自己的用户相同.
为了测试这个想法,我编写了以下简单的Dockerfile:
FROM phusion/baseimage
RUN touch /root/uid-$UID
Run Code Online (Sandbox Code Playgroud)
测试它,docker build -t=docktest .然后docker run docktest ls -al /root显示文件只是命名uid-.
有没有办法在来宾构建过程中与Docker共享主机环境变量?
我有一个自定义子类,UILabel使用CoreText进行自定义绘图.我曾经使用在UIFont使用font属性访问它的标签上设置的字符串来绘制我的字符串.我还在字体中添加了一些特征.这是它的样子:
UIFont* font = [self font];
CTFontRef ref = CTFontCreateWithName((CFStringRef)[font name], [font pointSize], NULL);
CTFontRef italicFont = CTFontCreateCopyWithSymbolicTraits(ref, [font pointSize], NULL, kCTFontItalicTrait, kCTFontItalicTrait);
Run Code Online (Sandbox Code Playgroud)
这曾经很好地工作,直到新的ipad出现其视网膜显示器.当我执行CTFontCreateCopyWithSymbolicTraits调用时,它会产生一个nil返回值.我发现[font name]在这些新设备上返回".HelveticaNeueUI".在CTFontCreateWithName似乎好工作与这家民营字体的名字,但CTFontCreateCopyWithSymbolicTraits没有.然而,如果我使用[UIFont italicSystemFontOfSize:[font pointSize]]它创建一个斜体字体,则会创建一个[font name]仍然返回".HelveticaNeueUI" 的斜体字体.
我应该如何将我转换UIFont为CTFontRef能够CTFontRef在视网膜和非视网膜显示器上应用新的特征?