我正在将应用程序从 Ipad 移植到 mac.(我知道这听起来很奇怪)
I am porting an app from Ipad to mac. (I know that it sounds weird)
我坚持使用 NSScrollview.请指导我 contentsize , contentOffset 在 NSScrollview 中等效.
I stuck with NSScrollview. Please guide me contentsize , contentOffset equivalent in NSScrollview.
UIScrollView* uiScroll;
uiScroll.contentSize;
uiScroll.contentOffset;
uiScroll.contentSize = CGSizeMake(w,h);
uiScroll.contentOffset = CGPointMake(x,y);
=
NSScrollView* nsScroll;
nsScroll.documentView.frame.size;
nsScroll.documentVisibleRect.origin;
nsScroll.documentView.frameSize = NSMakeSize(w,h);
[nsScroll.documentView scrollPoint:NSMakePoint(x,y)];
或者甚至更好:
import AppKit
extension NSScrollView {
var documentSize: NSSize {
set { documentView?.setFrameSize(newValue) }
get { documentView?.frame.size ?? NSSize.zero }
}
var documentOffset: NSPoint {
set { documentView?.scroll(newValue) }
get { documentVisibleRect.origin }
}
}
注意:我使用了documentSize"(和documentOffset"),因为contentSize"与 NSScrollView 的现有属性冲突.
Notes: I used 'documentSize' (and 'documentOffset') because 'contentSize' conflicts with an already existing property of NSScrollView.
这篇关于NSScroll 视图中的 contentsize 和 contentOffset 等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!