Search code examples
xcodemacoscocoaosx-lion

Vertical NSLevelIndicator OSX


I wonder if there is a way of creating/modifying a NSLevelIndicator object so it can be positioned vertically, i.e. display discrete levels from bottom up, not from left to right, so it can be also used as element of interface-building library in Xcode?

There are lots of examples of such level displays in Apple and non-Apple OSX applications, and quite a few reasons why such an object should exist, yet how to create such an object for some reason (from what I can see in developer forums) seems either not worth asking or a "best kept secret".

Is there a template code which can be modified to into an object of such properties?

I haven't even faintest idea if such an object should really be written from scratch? Mission impossible?

Thanks in advance!


Solution

  • Try using

    [NSView setFrameRotation:90];
    

    it's sketchy but easier than a custom view

    Edit: Alternatively try

    [levelView setFrameCenterRotation:90];
    

    SetFrameRotation:90 rotated it around the bottom left axis for me so it ended up being clipped. This one rotates it around the centre so you should be able to see it. I just made a quick swift playground showcasing it: http://cl.ly/WsL8/Vertical%20LevelIndicatorView.playground.zip

    Edit again: If you're still stuck, I made a sample project with a vertical level indicator in objective-c: http://cl.ly/WrdH/levelindicator.zip