iPhone SDK:如何绘制具有半透明渐变和阴影的圆角矩形
我正在尝试通过为我的应用程序手动创建部分 UI(在本例中为图表)来在 iPhone 上进行绘图。 本质上,我想绘制一个带有圆角、阴影和半透明渐变的矩形作为矩形的填充。 这是我的 Photoshop 样机的屏幕截图: 替代文本 http://img36.imageshack.us/img36/6097/picture1nvf.png< /a>
我已经使用 CALayer 创建了一个带有阴影的实心圆角矩形,但是为了让形状和阴影完全显示出来,我必须设置一个不允许我的背景颜色使我的半透明渐变成为图层的唯一填充。
我已经在这方面工作了一段时间,并且已经阅读了整个核心动画编程指南,但我还没有取得任何进一步的进展。 我觉得答案就在我眼皮底下。
我缺少什么?
PSI 知道我可能可以使用图像文件来完成此操作,但我正在尝试这样做,因为我想学习,并且有一天我想用它做一些更精美的动画。
I'm experimenting with drawing on the iPhone by manually creating parts of the UI for my application (In this case a graph). Essentially, I want to draw a rectangle with rounded corners, a drop-shadow, and a semi-transparent gradient as the fill of the rectangle. Here is a screen shot of my photoshop mockup:
alt text http://img36.imageshack.us/img36/6097/picture1nvf.png
I've gotten has far as creating a solid rounded rectangle with a drop shadow using a CALayer, but in order to get the shape and drop shadow to show up at all I have to set a background color which does not allow me to make my semi-transparent gradient the only fill of the layer.
I've been working on this for a bit now, and have read the entire Core Animation programming guide but I haven't made any further progress. I feel like the answer is right under my nose.
What am I missing?
P.S.I know I could probably use an image file to accomplish this but I'm trying to do it this way because I want to learn, and someday I want to do some fancier animation stuff with this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)