给NSWindow一个背景图片 [英] Give NSWindow a background image

查看:138
本文介绍了给NSWindow一个背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我在Photoshop中创建了一个图像,它将与我的应用程序上的按钮对齐,现在我想把它作为我的窗口的背景图像,使图像上的字符将对应于

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)

基本上,我们的应用程序(而不是像1,2,3,4等)的文本。我已经制作了一个3x3的地图,数字是不同的字体,只是因为它看起来很漂亮。

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.

我创建了一个NSImageView,我把图像文件拖到它上面,所以我可以看到它,但我不能它是背景。

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.

我需要子类化NSImageView还是有一些简单的方法?

Do I need to subclass the NSImageView or is there some simple method?

m使用XCode 4,btw

I'm using XCode 4, btw

谢谢!

推荐答案

你应该能够做如下:

[window setBackgroundColor:[NSColor colorWithPatternImage:[NSImage imageNamed:@"myImage.png"]]];

这篇关于给NSWindow一个背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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