Interface Builder에서 창으로 드래그 한 사용자 정의 뷰를 하위 클래스로 만들었습니다. 마우스가 뷰의 경계에 진입하면 뷰의 높이를 변경하고 싶습니다. 내 문제는 높이 변화가 위쪽이 아닌 아래쪽이다. (BOOL)isFlipped
으로 뷰의 좌표를 뒤집어 봤지만 높이 변경 방향에 영향을주지 않습니다. 내가 아래쪽 방향으로 높이를 어떻게 바꿀 수 있는지에 대한 도움?뒤집힌 도면 좌표가있는 NSView 높이 방향
#import "ViewA.h"
@implementation ViewA
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
options:(NSTrackingMouseEnteredAndExited|NSTrackingActiveAlways)
owner:self
userInfo:nil];
[self addTrackingArea:trackingArea];
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect
{
[[NSColor redColor] setFill];
NSRectFill(dirtyRect);
}
- (BOOL)isFlipped {
return YES;
}
- (void)mouseEntered:(NSEvent *)theEvent {
NSRect rect = self.frame;
rect.size.height = 120;
self.frame = rect;
}
- (void)mouseExited:(NSEvent *)theEvent {
NSRect rect = self.frame;
rect.size.height = 90;
self.frame = rect;
}
@end
그러나 isFlipped 메서드를 구현하여 좌표계를 맨 위 왼쪽으로 뒤집습니다. – wigging
'isFlipped' 메서드는 직접 설정하지 않습니다. 뒤집은 좌표계를 사용하는 경우 YES를 리턴하도록 서브 클래스의 메소드를 대체합니다. 단지'isFlipped'를 YES로 설정하면 좌표계가 바뀌지 않습니다. – Rakesh
@ 개 빈 : 설명을 포함하도록 답변을 편집했습니다. – Rakesh