Animation in NSStatusItem - macos

I'm writing a status bar application for OS X and I want to use an animated 'loading' gif as the icon when waiting to download a file.
Passing the gif in an NSImage to the setImage: method of the NSStatusItem set the status bar icon as the first frame of the image, but was not animated. I put the NSImage in an NSImageView and passed that to the setView: method but then the status item didn't show up at all.
How can I do this?

you might wanna use the NSProgressIndicator of spinner style and use setView to it. I'm having the same problem as you.

Related

Animated App Icon for macOS

I have a question regarding macOS app icons. I've seen a number of animated icons before, but never really paid close attention to what was going on / how they were doing it. I was just wondering if there was any way to create an animated app icon that animates in the dock.
For example:
Is it possible to do this via an animated media file, or even programatically?
Years past, there is a new package called DSFDockTile.
Like this:
For a brief dock icon animation, you might loop the following code via a timer. (Untested Obj-C).
NSDockTile *dockTile=[[NSApplication sharedApplication] dockTile];
NSImageView *dockImageView=[[NSImageView alloc] init];
NSImage *iconImage=[NSImage imageNamed: ##MY_IMAGE_FRAME##];
[dockImageView setImage: iconImage];
[dockTile setContentView: dockImageView];
[dockTile display];

OS X Use NSImageView for NSWindow background

I am trying to use an NSImageView as the background for an NSWindow I have it setup and it shows the image just fine I am using the full size content view to have the image take up the whole window. The problem I am having is the title bar with the buttons is being placed over the image and it is a transparent white color.
Is there a way I can make the title bar for a window transparent?
I am dumb the answer I was looking for is to call
[self setTitlebarAppearsTransparent:YES];
Reading documentation works!

How to temporarily disable UIView background image from responding to mouse clicks in Interface Builder?

I have a UIView background image that I want to use for my view.
Now, on top of this image, I want to have buttons and position them relative to what I see in the image.
The problem is, these buttons were already added to the view before the background image was added. So now when I put the background image, entire view is background image and I am unable to access the buttons underneath it in Xcode.
Is there a way to tell Xcode that I am not interested in the UIView but actually the buttons that appear underneath it?
Check - (void)sendSubviewToBack:(UIView *)view in UIView
Would be something like
[self.view sendSubviewToBack:backgroundImageView];

IKImageBrowserView does not refresh unless user scrolls

We've got an IKImageBrowserView that displays a bunch of images. We asynchronously download those images in the background and cache them to disk. We then notify the IKImageBrowserView that the imageRepresentation has changed using KVC. e.g. didSetValueForKey:#"ImageRepresentation". However, it looks like IKImageBrowserView will only refresh itself to load the recently downloaded images if user scrolls the view (We embedded IKImageBrowserView inside an NSScrollView). Why is this the case? Is there anyway to force IKImageBrowserView to redraw a certain cell or all visible cells without waiting for user to scroll the view?
Try using the reloadData method.
[browser reloadData];
I've got a similar situation in which I am using a IKImageBrowserView to view images that are downloading. In my case, I create the initial set of images with a placeholder image and then download the image. As each comes in, I update the data source entry with a different image, increase the image version number, then use the reloadData method on the browser. I also turn off animations so that the user doesn't see the entire browser redraw, only the images that have been updated.
- (void) setImage: (NSImage *) image
{
[img release];
img = image;
[img retain];
imageVersion++;
}
The above is a setter method for my data item that implements the informal protocol.
https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/IKImageBrowserItem_Protocol/IKImageBrowserItem_Reference.html

Give NSWindow a background image

Ok, so I've created an image in Photoshop that will align with the buttons on my app, and now I'd like to make it the background image of my window so that the characters on the image will correspond to the keys on my app (a small calculator demo app I've been working on)
Basically, instead of giving buttons Text like 1,2,3,4, etc. I've made a 3x3 map with numbers of a different font just because it will look pretty
What I'm having difficulty with now is that I can't seem to make the image the background of my window.
I created an NSImageView and I dragged the image file onto it, so I can see it now, but I can't make it the background.
Do I need to subclass the NSImageView or is there some simple method?
I'm using XCode 4, btw
Thanks!
I think you should be able to do something like:
[window setBackgroundColor:[NSColor colorWithPatternImage:[NSImage imageNamed:#"myImage.png"]]];
This is something that a layer-backed window would be good at:
[[window contentView] setWantsLayer:YES];
[[window contentView] layer].contents = myImage;
I think you stand a better chance of getting this to resize sensibly (assuming you need to) than with a pattern color.
Just to give you more options -- you should be able to [window setContentView:myImageView]. In the .xib file you'd want to add your buttons etc. as subviews of the image view.
I don't necessarily recommend this approach, but it's something to think about.

Resources