I've seen this toolbar-like UI element in a couple of apps, and I'd like to know if there's a standard Cocoa object for such an element.
Xcode:
ColorSchemer:
CornerStone:
If a standard Cocoa implementation does not exist, can anyone suggest a good open-source library?
In the second example, the buttons are what Interface Builder calls "Gradient Buttons" which have that appearance without needing a background image. The buttons are just butted up next to one another.
In the other examples, the "toolbar" is just an ordinary NSView with a custom image background, with standard NSButton objects as subviews. The buttons have their border disabled so all you see is the icon.
To get the "inset" look for the icons, the button images are most likely template images. To make an image a template image, it must consist of black and clear colors only, with an alpha channel. You then call [image setTemplate:YES] on the NSImage object.
Apple supplies some pre-canned template images which you can access by using the +imageNamed: method of NSImage.
In the case of Xcode, it's a private class called IDENavigatorFilterControlBar, with this inheritance hierarchy:
IDENavigatorFilterControlBar
IDEFilterControlBar
DVTBorderedView
DVTAutoLayoutView
NSView
DVT is the prefix used by the private Developer Tools framework.
Not sure if this is what you want, but have you tried Matt Gemmell's MGScopeBar?
Related
Tools: xCode, Objective-C, Mac, Cocoa
Purpose: I am creating a collection view with many buttons.
Each button opens a file in a folder and each of them has a background picture of the file (for example: jpeg file) so it looks like what you would see in a folder.
Question: How to make each button have a different image? Also, is this too difficult for a beginner?
P.S. : If i did this without the collectionview option, I would just drag the button on xib and change their background images, however I need my window to be collapsable and scrollable, hence I am using the collection view.
I would very much appreciate any comments/help/answers. Thanks!
This should not be difficult. A CollectionView holds a collection of CollectionViewItems. Inside the Item you can create any views you need. One of them could be an NSImageView that you set at runtime to the image you like. I suggest to play around with CollectionView and some f the samples Apple provides on it.
I'm building a iOS app which involves lots of photos displayed as rectangular areas on the screen. You can click on that area and see a bigger version of the photo. Kind of like those wallpaper apps, where you first see a grid layout of small wallpapers and then you can go in to see a bigger version.
So, I'm wonder what's the pros/cons in terms of memory usage and scalability between setting them up as UIButton (w/ background) and UIImageView?
I'd use an UIButton. It's easier to use as a user because it's made for touching them. Since UIImageView directly inherits from UIView it doesn't really know targets and selectors. So you'd have to implement this using touchesBegan:withEvent:. UIImageView is more efficient at drawing pictures though. UIButton already knows that so you'd only have to set the picture.
I have a button and its type is UIButtonTypeRoundedRect, but its border does not go along the rounded corner. How can I curve the border.
Check out this blog post I recently wrote: UI Polish in An Instant
You're on the right track accessing the button's layer property, but there is more you need to do (for example, to get rounded corners, add deleteButton1.layer.cornerRadius = 10), and more you can do, all without extra images.
Images are the recommended method for creating custom buttons. Apple's built-in buttons are basically only there for prototyping.
You could also create a subclass of UIButton and then override the methods for drawInRect and provide custom drawing code, probably using CoreGraphics. However, it is still much cleaner in code and more efficient at runtime to just use images.
I'm guessing it is using a custom NSWindow, NSTextField, NSSecureTextField, NSButton? I don't necessarily want to replicate it, I would just like to know what would be involved in customizing my app's UI to this level.
The window itself could be a HUD-style panel, which you can get in IB without subclassing anything. It looks like there's a bit of custom background to it, unless it's just faintly showing something behind it; if it is a custom background, a custom view as the content view could do that job.
The separator could be an image view or a custom view.
The static text fields can be done without subclassing. Just change the text color.
The editable text fields, both the regular one and the secure one, you would need to subclass. I have no idea how you would do that.
The follow-link button is a mix of custom drawing and a standard image. Start with the NSImageNameFollowLinkFreestandingTemplate image; draw that, then fill an empty path with white using the source-in blend mode.
The other two buttons are customized, probably using custom cells in order to override the background without overriding the text drawing.
By default, Cocoa adds a background blur effect to transparent and semitransparent modal sheets when they are applied to a window. I would like to disable the blur effect. How would I go about doing it?
I have created a custom sheet (a subclass of NSWindow with a transparent background and some controls in it). I am able to display it using the standard beginSheet method as follows:
[NSApp beginSheet:myCustomSheet
modalForWindow:mainWindow
modalDelegate:self
didEndSelector:...];
The sheet displays fine, but everything behind it is blurred.
Note 1: I am writing a completely customized user interface for a touch screen / kiosk type app, so none of the usual Apple user interface guidelines apply.
Note 2: I do want to see what is underneath the sheet. As SirRatty pointed out, it is possible to block out the blurred portion by filling in the background. In my case, I want to have the background show through, just without appearing blurred.
There's a private API call that can be used to set a CI filter on the background of a window:
http://www.mail-archive.com/cocoa-dev#lists.apple.com/msg16280.html
There's also a CGSRemoveWindowFilter:
extern CGError CGSRemoveWindowFilter(CGSConnectionID cid, CGSWindowID wid, CGSWindowFilterRef filter);
Just be aware that the usual private API caveats apply (might go away or change in the future, etc.).
What I've done:
In IB, add a window-sized custom NSView to the window, at the bottom of the content view hierarchy. Set the object's class to MySolidView (or whatever.)
In Xcode, the MySolidView class does just one thing: on -drawRect it will fill the view with a solid color. (e.g. light grey).
You could write your own sheet animation routines that display your own NSWindow and fill the background of the window with a semitransparent colour. I'm not sure whether setAlphaValue: for NSWindow will also affect the child elements' opacity. If it does affect them, you could use setBackgroundColor: and provide the default window background colour but with an alpha component, this should not affect the child elements.
I suppose one of the problems of developing/designing your own user interface is when you have to reimplement the wheel just for a minor customisation. At least, if you write it yourself, you'll have more control over its customisation in the future.