
现在需要将其更改为在右边,并将其图片更改:

实现方法如下
1 自定义NSOutlineView
@interface LYOutlineView : NSOutlineView
@end
2 重写- (void)layout方法
[super layout];
for (NSView *view in self.subviews) {
for (NSView *subView in view.subviews) {
if ([subView.identifier isEqualToString:NSOutlineViewDisclosureButtonKey]) {
// 设置图片
NSButton *disclosure = (NSButton *)subView;
disclosure.imageScaling = NSImageScaleProportionallyUpOrDown;
disclosure.image = [NSImage imageNamed:@"jiantouyou"];
disclosure.alternateImage = [NSImage imageNamed:@"jiantouxia"];
// 设置frame
CGFloat x = view.frame.size.width - 100;
CGFloat y = disclosure.frame.origin.y;
[disclosure setFrameOrigin:NSMakePoint(x, y)];
}
}
}
网友评论