[英]UI issues with custom NSBox
我有一個子類NSBox。 在內部,我嵌入了一些NSTextfields,它們的角落處顯示了一些奇怪的偽像(請參見此處的圖像 )。 這是我的NSBox子類代碼:
- (void)drawRect:(NSRect)rect {
NSBezierPath* rectanglePath = [NSBezierPath bezierPathWithRoundedRect:rect
xRadius: 4
yRadius: 4];
[NSColor whiteColor];
[rectanglePath fill];
}
有任何想法嗎? 謝謝托馬斯
解決問題的方法是使用[self bounds]而不是rect參數。
- (void)drawRect:(NSRect)rect {
NSBezierPath* rectanglePath = [NSBezierPath bezierPathWithRoundedRect:[self bounds]
xRadius: 4
yRadius: 4];
[NSColor whiteColor];
[rectanglePath fill];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.