如何使NSButton上面的NSButton? [英] How to make the NSButton above a NSButton?

查看:298
本文介绍了如何使NSButton上面的NSButton?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个NSButtons。两个按钮是与图像。这是我创建的[buttons]( http://i.stack.imgur.com/IYXIE .png )问题是星形按钮总是位于叶子按钮后面。我怎么能把它带到前面。 (搜索Mac osx而不是iOS。)

更新:
这是我在第一次鼠标悬停时获得的,第二次鼠标移到

i'm having two NSButtons. Both button were with images. This is what i created [buttons] (http://i.stack.imgur.com/IYXIE.png) the problem is the star button always located behind the leaf button. how can i bring it front. (searching for Mac osx not iOS.)
UPDATE: this is what i got during first mousehover , got this during second mouse over

推荐答案

[starButton removeFromSuperview];
[self addSubview:starButton positioned:NSWindowAbove relativeTo:nil];

此外,NSView支持方法

Also, NSView supports the method

 sortSubviewsUsingFunction:context:

。需要更多的代码,但看起来更干净。

implement that to simply sort the views.. requires more code but seems more clean.

这篇关于如何使NSButton上面的NSButton?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆