문제

I have this idea of having some kind of "badges" in my app. They should be clickable, have an image and a label. That's the easy part. But I also want them to have this little help button in the upper right corner which is also clickable. The help button should just be an image and should of course also be clickable. What would be the best approach of having this small button inside a larger button? Should I have two buttons above each other?

도움이 되었습니까?

해결책

My suggestion is to bypass trying to beat NSButton into something its not. You can cook up your own "Button" with an NSView or Hierachy of NSViews.

If you are really determined to go the NSButton route perhaps assemble the multiple buttons inside inside an NSView which would be possible inside IB or programatically something like

NSView *container = [[NSView alloc] initWithFrame:NSMakeRect(0,0,100,100)];
NSButton *big = [[[NSButton alloc] initWithFrame:NSMakeRect(0,0,100,100)] autorelease];
NSButton *small = [[[NSButton alloc] initWithFrame:NSMakeRect(80,80,20,20)] autorelease];
[container addSubview:big];
[container addSubview:small];
[small setImage:[NSIMage imageNamed:@"query.png"]];
[big setImage:[NSIMage imageNamed:@"cow.png"]];
[big setTitle:@"cow"];

You'd have to beat the buttons into shape a little more but thats the basics.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top